$_FILES Empty After File Upload

I’m using this form to try to upload a file.

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN'
'http://www.w3.org/TR/html4/strict.dtd'>
<html>
 <head>
  <title>Music Vids</title>
 </head>
 <body>
  <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
   Section: <input type="text" name="section"><br />
   <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="102400000" />
   <input type="file" id="userfile" name="userfile" /><br />
   <input type="hidden" id="action" name="action" value="upload" />
   <input type="submit" value="Submit" />
  </form>
 </body>
</html>

Something wasn’t working, so I had the form’s action go to printr.php which basically prints (using print_r) out all the PHP superglobals. That returns nothing, so I’m completely lost.

I know it’s not the MAX_FILE_SIZE, since the max upload file size is 100M, if that helps.

Hi, the variables passed from the posted form when you use a file upload are passed in a seperate global $_FILES.

You can use that to find out information about the file.

on your print_r page, echo the $_FILES array as well as the $_POST array.

Cheers

SpikeZ

PS Over 30 and trying to hide it!

This is what I’m using for printing out all the superglobals, and I’m get nothing with it . . .

<html><body><pre>
<?php
# Yes, I am that lazy :p
function br() { echo '<br />'; }

echo 'post: ';
print_r($_POST);
br();
echo 'get: ';
print_r($_GET);
br();
echo 'cookie: ';
print_r($_COOKIE);
br();
echo 'files: ';
print_r($_FILES);
br();
echo 'request: ';
print_r($_REQUEST);
?></pre></body></html>

Try this:

<?php
if(isset($_POST['submit'])){
        echo '<pre>';
        print_r($_FILES);
        echo '</pre>';
        }
?>
<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
<html>

<head>
 <title>Music Vids</title>
</head>

<body>
 <form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
 Section: <input type="text" name="section"><br />
 <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="102400000" />
 <input type="file" id="userfile" name="userfile" /><br />
 <input type="hidden" id="action" name="action" value="upload" />
 <input type="submit" value="Submit" name="submit"/>
 </form>
</body>
</html>

Well, that works, and I just realized that my other form works too.

It seems that PHP can’t upload .mpg files. bangs head on desk

Sorry, everyone