Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic multiple file upload not working on mobile

I created a very basic example of a multiple file upload form (reference), it works perfect on desktop but not on mobile, at least the ones I am testing with.

On Mobile (Xiaomi Mi4 [Android version: 6.1] - Google Chrome/Mozilla Firefox): When I click on Choose files I see this screen:
enter image description hereenter image description here

If I choose Google Photos and select multiple files, only the first file will be inserted into the form. If I select the Gallery (native) app and select multiple files I get the correct number on the form but when I click upload I get the "Aw Snap" screen:

enter image description here

Any idea why this is happening?

Besides Google Photos and the native app I tried 5 different apps, the last one, Piktures actually worked!

Please tell me this is not an app thing... is there a way to get the files correctly?

Code attached:

<form method="post" enctype="multipart/form-data">
        <input type="file" name="my_file[]" multiple>
        <input type="submit" value="Upload">
    </form>
    <?php
        if (isset($_FILES['my_file'])) {
            $myFile = $_FILES['my_file'];
            $fileCount = count($myFile["name"]);

            for ($i = 0; $i < $fileCount; $i++) {
                ?>
                    <p>File #<?= $i+1 ?>:</p>
                    <p>
                        Name: <?= $myFile["name"][$i] ?><br>
                        Temporary file: <?= $myFile["tmp_name"][$i] ?><br>
                        Type: <?= $myFile["type"][$i] ?><br>
                        Size: <?= $myFile["size"][$i] ?><br>
                        Error: <?= $myFile["error"][$i] ?><br>
                    </p>
                <?php
            }
        }
    ?>

If you wish to test: http://odedta.com/projects/jqueryfileupload/

Thanks!

like image 377
odedta Avatar asked Oct 30 '17 08:10

odedta


People also ask

How do you upload multiple files in SAP?

Procedure. Choose Folder New Multiple File Upload . Choose Select Files, and in the Select files for upload dialog box, select the files that you want to upload. The system displays the files in the Selected Files list.

How do I upload multiple files to dropzone?

drag and drop multiple files into a Dropzone. see the upload process (percentage) of each file with progress bars. view all uploaded files. download link to file when clicking on the file name.


1 Answers

Try this might help you this is only front end part of file upload with js

window.onload = function() {
  if (window.File && window.FileList && window.FileReader) {
    var filesInput = document.getElementById("uploadImage");
    filesInput.addEventListener("change", function(event) {
      var files = event.target.files;
      var output = document.getElementById("result");
      for (var i = 0; i < files.length; i++) {
        var file = files[i];
        if (!file.type.match('image'))
          continue;
        var picReader = new FileReader();
        picReader.addEventListener("load", function(event) {
          var picFile = event.target;
          var div = document.createElement("div");
          div.innerHTML = "<img class='thumbnail' src='" + picFile.result + "'" +
            "title='" + picFile.name + "'/>";
          output.insertBefore(div, null);
        });        
        picReader.readAsDataURL(file);
      }

    });
  }
}
<input type="file" id="uploadImage" name="termek_file" class="file_input" multiple/>
<div id="result" class="uploadPreview">
like image 80
Nisal Edu Avatar answered Sep 22 '22 16:09

Nisal Edu