Page 1 of 1

Get Duration of Audio file when Upload

Posted: 20 Sep 2015, 10:57
by Marius
Hello,
I have a form to upload audio files on server. The name of the file, path and size is stored into a table in database.
The script is working, I can get the size of the uploaded file with: $_FILES['field_name']['size']. But, how can I get the duration of the audio file (MP3 and OGG)?
I want to store in database the duration in seconds.
Thanks.

Get Duration of Audio file when Upload

Posted: 20 Sep 2015, 11:00
by Admin
Hy,
You can get the duration of an audio /video file with JavaScript. Then, with JS you can add the duration into an input field in the form for upload.
See the code and explanations from this page: https://coursesweb.net/javascript/durati ... -upload_cs