问题描述:

I'm having issues using HTML5 to upload files in iOS. On the desktop I can happily select multiple files and upload them. However on iOS 6.0 (the only iOS I've tested) if I try and upload 2 files it uploads the first image twice. This is true whether they have been selected in the same input, or if the form includes different inputs. As soon as the form has more than one file, the first file is repeated, replacing the other files.

This code below and similar code with multiple input fields work on Android Chrome, Windows IE, Windows Chrome, & Mac Firefox.

<form class="upload" action="UploadServlet" method="post" enctype="multipart/form-data">

<fieldset>

<input id="filename" type="file" name="file" size="10" multiple/>

<input id="submitButton" name="submit" type="submit" value="Submit"/>

</fieldset>

</form>

The same issue with different code related to multiple uses of the camera:

<form class="upload" action="UploadServlet" method="post" enctype="multipart/form-data">

<fieldset>

<input id="filename" type="file" name="name" size="10" capture="camera"/>

<input id="filename1" type="file" name="name1" size="10" capture="camera"/>

<input id="submitButton" name="submit" type="submit" value="Submit"/>

</fieldset>

</form>

Many thanks in advance!

Richard

网友答案:

With the help of a colleague we tracked this down. Turns out any images being passed by iOS are all given the filename image.jpg. This was causing my server to save each file over each other. A simple fix was to dynamically name the uploaded images on the server side.

On a php backend, we also found that the html input name attribute needed [] ie:

<input id="filename" type="file" name="file[]" size="10"  multiple/>
相关阅读:
Top