1

Have a WordPress Gravity Forms standard upload field where users can upload a video file.

I'd like to limit uploads to be 60 seconds or less. If I can get the number of seconds of the uploaded video into a php variable, I should be able to take care of the validation from there.

This SO shows how to do it in javascript (though that example seems to work in Chrome but not Safari) How to Check Length / Duration of an Uploaded Video in JavaScript. Getting that javascript value to php would be a challenge I imagine, so hoping to find more a php solution if possible to be used in a custom wordpress function?

Unless there is a way to get that javascript seconds value into php. I saw a question using, "ffmpeg" but that was for a video already uploaded this would be for validating before form submission.

While noted above, just adding again this is in regards to accomplishing it in PHP (the other questions I've seen are in regards to accomplishing in javascript) and ultimately I need the value sent to a php wordpress function.

TechRemarker
  • 2,788
  • 11
  • 37
  • 60
  • Possible duplicate of [Get video duration when input a video file](https://stackoverflow.com/questions/29285056/get-video-duration-when-input-a-video-file) – cmorrissey Aug 29 '17 at 19:44
  • @cmorrissey yes I saw that as well, however that also looked to be integrating with javascript rather than with php which this question is about. Can you confirm that other question is for accomplishing this in php? – TechRemarker Aug 29 '17 at 20:05
  • you can accomplish it with php but the whole file will needs to be uploaded to your server first. So you can soft check with JS and then check once the file is uploaded again to confirm the length. – cmorrissey Aug 29 '17 at 20:09
  • 2
    @cmorrissey It would need to be checked before the form is submitted. After the video is uploaded there are built in functions in Wordpress for detecting video length, so thats not the challenge, having it before video is uploaded is the challenge. So maybe a combination of javascript to detect and then somehow passing that info to php, but I no in general those two don't really interact so hoping to find a potential solution workaround here. If you believe its not possible please not that as an answer rather than marking as a duplicate since that question is different. Thank you! – TechRemarker Aug 29 '17 at 20:12

0 Answers0