homepage Welcome to WebmasterWorld Guest from 54.196.225.45
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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




msg:3648058
 5:33 pm on May 12, 2008 (gmt 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
(
)

 

wheelie34




msg:3648128
 7:04 pm on May 12, 2008 (gmt 0)

The above code looks ok, the problem may be on submit.php how are you handling the images?

Duskrider




msg:3648183
 7:50 pm on May 12, 2008 (gmt 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.

omoutop




msg:3648664
 8:39 am on May 13, 2008 (gmt 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.

homeini




msg:3648673
 9:14 am on May 13, 2008 (gmt 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!

eelixduppy




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

Just out of curiosity, what browser and version are you using?

homeini




msg:3649011
 5:01 pm on May 13, 2008 (gmt 0)

I don't remember it so well, but Mozilla 1.7.12 or Firefox 2.0.0.11

eelixduppy




msg:3649017
 5:08 pm on May 13, 2008 (gmt 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
redhat



msg:3689457
 6:55 am on Jul 3, 2008 (gmt 0)

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)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved