neurofuzzy, flash game development, rich internet applications, free source code – *alt.neurotica.fuzzy*

neurofuzzy, flash game development, rich internet applications, free source code – *alt.neurotica.fuzzy*

7/9/2006

Safari and PHP, File Uploads Solved!

Filed under: PHP — geoff @ 12:16 am

I posted recently about image file uploads to PHP, and how they would fail in Safari.  It was a nasty bug that wouldn’t go away, but I finally discovered the problem.  On my upload form, I was using javascript and CSS to hide the form fields and replace them with an “Uploading files…” prompt.  It seems that there’s a bug in Safari where hidden forms will contain no values.  So, in hiding my form, nothing was being sent to my site!

I was wondering why my $_FILES array was empty – it just didn’t make any sense.  After I stopped hiding my form, I instead covered over it with the ”Uploading…” dialogue using relative positioning.  Now the $_FILES array was being populated and the files sent via POST.  It works like a charm now!

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

7 Comments »

  1. Just wondering, did the bug also exist if you made the form invisible (as opposed to hidden) ?
    CSS:
    visibility=hidden;

    I don’t have Safari to test on.

    Comment by Mike — 7/14/2006 @ 8:52 am

  2. As I’ve run into the same right now …
    yes, it happens also if you just hide it through visibility.

    Comment by thomas — 9/9/2006 @ 5:38 am

  3. I got the Same problem
    was working fine with IE 5.5 and 6,
    Firefox was sending the form , at least in parts , but the files were not uploaded by Firefox.

    After reading this article i found that:

    I usually put my forms , in between table cell or rows, That was preventing some problem with multiple forms , and the way the browsers display them, something they were acting like instead of being seamless.

    Firefox doesnt like’s the forms to be “not shown” i mean that , even if it is there in the page, and it properties are the basic one,
    the was in between a table cell , usually nothing goes there.
    but it was beeing used correctly by explorer.
    and the were in the table cell so they can be seen

    and i had no problem with form having a style of theire own.

    after reading this , i moved the in a normal place eg: in

    instead of

    this way firefox , send the whole and the uploaded files correctly

    Comment by JR — 9/18/2006 @ 1:55 pm

  4. I was reading your SAFARI and PHP solution, thanks, I will investigate this. My web site, when the users submit or calculate their forms get a “not a number” error message when they swear they are putting in values. Does not happen with firefox on the MAC.
    Have a look at the site, vote and tell everyone you know to get the vote out!
    (Assuming you live in the USA)
    Thanks again!
    John S

    Comment by John S — 4/29/2007 @ 3:26 am

  5. Hi,
    Please provide me source code for
    Safari and PHP, File Uploads Solved!.
    thanks,
    Bhaskara.

    Comment by bhaskara — 11/14/2007 @ 4:53 am

  6. I was having the same issue until I read this. I also have some other advice for you.

    You don't need to use relative positioning. Just make sure that you use inline CSS in the element that you've been hiding to show that visibility: inherit.

    It acts a little nicer when you do that. At least for Safari for Windows. :)

    Comment by Ducky — 11/11/2008 @ 9:21 am

  7. For the record this bug also affects Konqueror 3.5.7 (as it shares the same rendering engine as earlier Safaris).

    Making the CSS inline doesn't work though. You need to not hide the form and position a layer over the top.

    Comment by senyahnoj — 11/12/2008 @ 10:19 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

 

Powered by WordPress