I have a form that I upload a video, and the duration / length of the video is important.
After I upload the file using PHP, I check the length of the video file using FFMpeg .
I am calculating the duration in PHP and have to somehow send the duration value through PHP. I think I should add duration to the $result Json variable.
This is my html
<!DOCTYPE html> <html> <head> <script src= "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="https://rawgit.com/enyo/dropzone/master/dist/dropzone.js"></script> <link href="css/dropzone.css" rel="stylesheet"> <script type="text/javascript"> Dropzone.options.myDropzone = { maxFiles: 1, acceptedFiles: "image/*,video/*", maxfilesexceeded: function (file) { this.removeAllFiles(); this.addFile(file); $('#infomsg').hide(); }, init: function () { $('#infomsg').hide(); this.on("success", function (result) { $('#infomsg').show(); $("#boatAddForm").append($('<input type="hidden" ' + 'name="files[]" ' + 'value="' + result.name + '">')); }); } }; </script> <title></title> </head> <body> <p> This is the most minimal example of Dropzone. The upload in this example doesn't work, because there is no actual server to handle the file upload. </p> <form action="/dropzone/upload.php" class="dropzone" id="my-dropzone" name="my-dropzone"></form> <form action="/dropzone/son.php" id="boatAddForm" method="post" name= "boatAddForm"> <input class="submit" type="submit"> </form> </body> </html>
This is my php
<?php $ds = DIRECTORY_SEPARATOR; $storeFolder = 'uploads'; if (!empty($_FILES)) { $tempFile = $_FILES['file']['tmp_name']; $targetPath = dirname( __FILE__ ) . $ds. $storeFolder . $ds; $targetFile = $targetPath. $_FILES['file']['name']; move_uploaded_file($tempFile,$targetFile); } else { $result = array(); $files = scandir($storeFolder); //1 if ( false!==$files ) { foreach ( $files as $file ) { if ( '.'!=$file && '..'!=$file) { //2 $obj['name'] = $file; $obj['size'] = filesize($storeFolder.$ds.$file); $result[] = $obj; } } } header('Content-type: text/json'); //3 header('Content-type: application/json'); echo json_encode($result); }
If I could check the json user response right after
Dropzone.options.myDropzone = {
like other requirements for success, I will not be eligible if the allegations are successful in order to verify validation.
I basically want to do it as I like
maxFiles: 1,
without writing any conditions inside success
source share