Welcome to WebmasterWorld Guest from 54.163.25.166

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

$ FILES is empty

When I send a multipart form with a file $_FILES appear empty

     
5:33 pm on May 12, 2008 (gmt 0)

New User

5+ Year Member

joined:June 28, 2007
posts: 17
votes: 0


Hello,

I've got a simple form to send a photo. But when I send it $_FILES appears empty.

I've write enctype="multipart/form-data" in the HTML so I don't understand what happend.

The HTML:


<form action="submit.php" method="post" name="registerForm" enctype="multipart/form-data">

<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td>Photo (max-width:800px):</td>
<td class="main "><input type="file" name="photo">&nbsp;<span class="inputRequirement">*</span></td>
</tr>

<tr>
<td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="10"></td>
</tr>

<tr>
<td class="main" style="padding-left: 7px"><input type="submit" value="Enviar" /></td>
<td>&nbsp;</td>

</tr>
</table>
</form>

The PHP:


print "<pre>";
print_r($_POST);
print_r($_FILES);
print "</pre>";

The Result:


Array
(
[photo] => prueba.jpg
)
Array
(
)
7:04 pm on May 12, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 6, 2005
posts:863
votes: 0


The above code looks ok, the problem may be on submit.php how are you handling the images?
7:50 pm on May 12, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:May 31, 2006
posts:116
votes: 0


You may need to set the MAX_FILE_SIZE attribute in your form.

EX:
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000000">

As I recall I could never get file submission to work without that set on the form before the actual file field.

8:39 am on May 13, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 15, 2004
posts: 941
votes: 0


assuming you have checked on mispelled words:

activate error reporting: error_reporting(E_ALL); (put this on top of your page)

make sure SAFE MODE is off - you cant upload anything via php in safe mode.

9:14 am on May 13, 2008 (gmt 0)

New User

5+ Year Member

joined:June 28, 2007
posts:17
votes: 0


Thanks all!

The problem was fixed with the solution gave by Duskrider.

I forgot the hidden MAX_FILE_SIZE field. Now it's working perfectly.

Bye!

4:26 pm on May 13, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


Just out of curiosity, what browser and version are you using?
5:01 pm on May 13, 2008 (gmt 0)

New User

5+ Year Member

joined:June 28, 2007
posts:17
votes: 0


I don't remember it so well, but Mozilla 1.7.12 or Firefox 2.0.0.11
5:08 pm on May 13, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


The only reason I was curious is because it should still show the $_FILES array when you print it out. I haven't seen it where it hasn't before when it was missing that hidden form element. Maybe it's certain versions of FF? It works fine without it for me. Anyway, you should have been getting the corresponding error value [us2.php.net], I'd imagine, instead of having no array at all.

Anyyyway....I'm glad you have yours working. Thanks for the additional information. If I find out more on this topic, I'll be sure to let everyone know :)

System

6:55 am on July 3, 2008 (gmt 0)

redhat

 
 


The following 2 messages were cut out to new thread by eelixduppy. New thread at: php/3689455.htm [webmasterworld.com]
10:42 am on July 3, 2008 (est -4)