Forum Moderators: coopster

Message Too Old, No Replies

Opera form submission problem

specifically, an <input type="file"> is submitted even if left blank ..

         

Warboss Alex

9:05 am on Aug 22, 2004 (gmt 0)

10+ Year Member



Hey everyone,

I've just discovered a peculiar problem which only occurs in the Opera browser.

I've got my nice PHP user management system, with a form for users to post their info (name, location, email, hobbies etc) .. and I've also got a file field for an OPTIONAL photo/avatar.

Like I said, the photo file is entirely optional, and is validated server-side to be a jpg or gif in the correct dimensions.

In Opera, even if the field is left blank, something is seemingly uploaded to the server, because the image validation always fails unless a picture is actually uploaded (even if the field's empty) .. This only happens in Opera. Firefox, IE and Netscape all don't mind the photo field is left blank and process the form normally.

Can anyone help?

Alex ...

dcrombie

9:44 am on Aug 22, 2004 (gmt 0)



A blank "file" input generally passes the value "none".

Warboss Alex

9:47 am on Aug 22, 2004 (gmt 0)

10+ Year Member



My validation checks for that.

it only validates if ($_FILES['icon']['error']!== 4). (a value of 4 means there was nothing uploaded).

So, if it's validating as if something was uploaded, Opera sent some sign that it sent a file to the server.

I think.

dcrombie

10:07 am on Aug 22, 2004 (gmt 0)



Have you tried:

<pre>print_r($_FILES);</pre>

Warboss Alex

10:39 am on Aug 22, 2004 (gmt 0)

10+ Year Member



Yes, it's an empty array.

Warboss Alex

10:40 am on Aug 22, 2004 (gmt 0)

10+ Year Member



Duh. That's it. I'll make sure the array isn't empty too.

I was just wondering if this was a known Opera bug..