Custom Forms w/ File Upload and iOS

This issue took me a while to finally track down, but I finally figured out what the problem was.


We had an Alumni who said one of our forms didn't work, after a long time tracking the issue down, I realized she was using an iPad. Our form has a file upload field so that Alumni can upload an image if they want. This field is optional.



The problem arises when a user is on iOS (iPhone/iPod Touch or iPad) because Safari on iOS doesn't allow file uploads, it just greys out that field. This is fine, it isn't a required field. But, Matrix will continually throw a form error telling the user that there was an error uploading the file. Now, my assumption was that if this field is optional, it shouldn't be a problem. But, I am assuming that the PHP is still looking for the file input to be sent through POST. But, since iOS Safari blocks file fields, the PHP never gets this through POST and thinks it is an error.



I tried to trick Matrix into thinking everything was ok by creating a dummy hidden input field with the same name, just so that POST would have something to receive, but that didn't seem to work either. Is Matrix also checking to see what kind of field this is and knows that my fake hidden field is not of type file?



Does anyone have any ideas or workarounds that they can think of?

I filed a bug for it.
http://bugs.matrix.squiz.net/view_bug.php?bug_id=5574



When you upload via normal browsers, PHP does recognize there is a file upload. It stores the upload info in $_FILES system variable.

If there is no file uploaded, it also stores the status of "no file uploaded" in it.

However, if IOS submits the form, there is no info in $_FILES at all. So Matrix thinks it's a failed upload.



I don't know how you can fake up the post data. I can use Firebug to find out the post data is like below.



-----------------------------104478812419277021961952509530 Content-Disposition: form-data; name="q7932:q1"; filename="" Content-Type: application/octet-stream





I think it's better to fix it in Matrix, so that it treats empty $_FILES as no file uploaded, rather than thinking it's a failed upload.

[quote]
I filed a bug for it.

http://bugs.matrix.squiz.net/view_bug.php?bug_id=5574

[/quote]



Wonderful! Thanks for the bug submission and explanation!

Hey my toaster is having a problem uploading a file via a form in matrix. Is it also a bug? :stuck_out_tongue: :P’ /> <img src=‘http://forums.squizsuite.net/public/style_emoticons/<#EMO_DIR#>/cool.gif’ class=‘bbc_emoticon’ alt='B)

[quote]
Hey my toaster is having a problem uploading a file via a form in matrix. Is it also a bug? :stuck_out_tongue: :P’ /> <img src=‘http://forums.squizsuite.net/public/style_emoticons/<#EMO_DIR#>/cool.gif’ class=‘bbc_emoticon’ alt='B)

[/quote]



Good one. :slight_smile: