Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with file upload

Status
Not open for further replies.

akrug23

Programmer
Jan 17, 2005
2
0
0
US
I am trying to upload a picture file but it is not working. The tmp_name file is empty. Here is a sample of the code I am using. I know that it is basic but I am just trying to get it to work.

<?PHP
echo test1;
if (isset($_POST['add'])) {
echo test2;
echo $_POST['file']['error'];
echo $_POST['file']['tmp_name'];
echo $_POST['file']['name'];
echo test3;
}
echo test4
?>
<form action="<?PHP echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data" name="form1">
<p>
<input type="file" name="file">
</p>
<p>
<input name="add" type="submit" id="add" value="submit">
</p>
</form>

All the echos of the $_POST varibles returns nothing. Is there a setting in the set up of PHP in order to get this to work? Please Help.
Thak You Aaron
 
In PHP uploaded files are stored in $_FILES rather than $_POST. Your file information should be there. You can do:
Code:
echo '<pre>';
print_r($_FILES);
echo '</pre>';
to inspect what is in the array.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top