Uploading video file on website throw UIWebView in

2020-07-28 11:00发布

问题:

When I want to upload a video to my website, throw UIWebview using <input file="type"/> the files are picked from the Photo Library and the videos are compressed before being sent to the server. This works great in UIWebview! But now is there a way to get rid of that compression? a have a good quality video sent to the server.

  1. I try with multiple libraries like dropzonejs, file-uploader but no one seems to work in UIWebview when the videos are uploaded from the Photo Library (the compression step is skipped and the upload fail because of a file size that is equal to 0).

Strangely everything works fine in every case (UIWebview, Safari), when the video is uploaded from another app like (Documents) no compression done in any case so the video is sent directly.

What I also try:

  1. Look on iPad to disable some preferences in Photos and found nothing.

  2. I just take the simple example: http://www.dropzonejs.com/examples/simple.html and did some testing and it seems that dropzone.js works well in Safari but not when accessed throw UIWebView.

  3. Load the vimeo website in UIWebview and try to upload video, it also fail saying that the video size is not valid (0B)

Any idea on how can I avoid the compression step when the photo is picked from the Photo Library using the simple <input file="type"/> which is the only one that worked with Photo Library in UIWebview?

Or is there a way to use libraries like dropzone.js and upload file throw UIWebview. Moreover every type of file works (music and images). It is only videos that are not correctly handled in UIWebview.

回答1:

I found that a workaround to the bug can be done by limiting the max number of files uploaded to one.

In Dropzone this means:

objFacilityDropzone = new Dropzone("#mainFileUploader",
    {
        url: "/posUrl",
        autoProcessQueue: false,
        addRemoveLinks: true,
        maxFilesize:100,
        acceptedFiles: "image/*,video/*,.mov,.mp4",
        maxFiles: 1,
   }


回答2:

I try your solution but it is not working for me… ios 13.2 here my code :

    <form action="/wp-content/uploads/upload_video/upload.php" class="dropzone" id="myAwesomeDropzone">
    <input type="text" id="post_id" name="post_id" value="<?php echo $_POST["property_id"];?>"/>
    </form>

                                         <script>
    jQuery(function($)
    {

    // "myAwesomeDropzone" is the camelized version of the HTML element's ID
Dropzone.options.myAwesomeDropzone = {
  paramName: "file", // The name that will be used to transfer the file
  autoProcessQueue: false,
        addRemoveLinks: true,
        maxFilesize:100,
        acceptedFiles: "video/*",
        maxFiles: 1,
        multiple: false,
        uploadMultiple: false,
  };
  alert("coco");
                                    });
                                    </script>