Jump to content
  • Advertisement
Sign in to follow this  
hplus0603

[web] _FILES doesn't contain my file (PHP 5 and Apache 2)

This topic is 4487 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a form that looks something like:
<form enctype="multipart/form-data" method="post">
  <input type='hidden' name='issue' value='06march'/><br/>
  <input type="file" name='picture' size='45'/><br/>
  <input type='text' size='40' name='caption'/><br/>
  <input type='submit' name='upload' value='Upload'/>  
  <input type='submit' name='cancel' value='Cancel'/>
</form>
I have a PHP script that looks something like:
  if( gpc( 'upload' ) ) {
    print( "_FILES: " ); print_r( $_FILES ); print( "<br/>\n" );
    print( "_POST: " ); print_r( $_POST ); print( "<br/>\n" );
    $tmp_name = $_FILES['picture']['tmp_name'];
    if( !is_uploaded_file( $tmp_name ) ) {
      error( "'$tmp_name' is not an uploaded file." );
    }
(The function gpc() just tries to get the argument from all three argument sources in order) When I browse to a file and try to upload it, it prints the following:
_FILES: Array ( )
_POST: Array ( [issue] => 06march [caption] => [upload] => Upload )

Notice: Undefined index: picture in 
/var/apache/htdocs/default/RPNS/upload/uploadpicture.php on line 18

Error: '' is not an uploaded file.
I have looked at the data sent from the browser with Ethereal, and it's sending the file alright (with a filename= attribute and everything). However, it doesn't show up in _FILES. My php.ini claims that max file size is 4000000, and file upload is enabled. Apache log doesn't show any errors (it shows up as a POST in access_log). Syslog does not show any errors. This happens both with Firefox and IE. What am I doing wrong? What more should I check?

Share this post


Link to post
Share on other sites
Advertisement
Sounds like it's definitely a server problem.

Have a look at your PHP error log (you do have one, right?) - make sure error_reporting(E_ALL) is set.

You've done all the right things to get this to work. I suppose one possibility is that the temp directory it keeps uploaded files in isn't writeable - but I'd expect PHP to throw at least a warning in that case.

Mark

Share this post


Link to post
Share on other sites
Error logging is set to E_ALL; error reporting is set to both HTML output and syslog. Neither shows a problem.

post_max_size is 8 MB, memory_limit is set to 16 MB, max upload size is 4000000, the file I'm uploading is about 60k. My Apache doesn't have a LimitRequestSize set.

I've done file uploads before, and it's worked, so I can't figure out what's wrong now. Nothing seems different. Frustration is mounting.

Share this post


Link to post
Share on other sites
Is it practical to do the form submission on the command line? That way you could perhaps feed it to PHP directly and at least narrow down whether it's PHP or Apache that's misbehaving.

Share this post


Link to post
Share on other sites
I got the latest Apache and PHP sources and did a full re-build, and it seems to give me the right data now. Weird, given that I've been running this install until now for longer than I should have ;-)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!