Jump to content

[SOLVED] $_POST not working with $_FILES


aeonsky

Recommended Posts

For some reason, it always shows just the form. Never actually submits anything. Thanks for the help.

 

<?PHP 

if ($_POST['uploadedfile']) {

$target_path = "uploads/".basename($_FILES['uploadedfile']['name']); 

if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    	echo "The file ".basename( $_FILES['uploadedfile']['name'])." has been uploaded";
} else {
    	echo "There was an error uploading the file, please try again!";
}

} else {

print <<<SHOW
<form enctype="multipart/form-data" action="{$_SERVER['PHP_SELF']}" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<input name="uploadedfile" type="file" />
<input type="submit" value="Upload File" />
</form>

SHOW;

}

?>

Link to comment
https://forums.phpfreaks.com/topic/130364-solved-_post-not-working-with-_files/
Share on other sites

Because PHP is smart enough to move it to $_FILES and not bother with setting it in $_POST.  At least I'm pretty sure that it shouldn't appear in $_POST.

 

Yeah, it doesn't go in $_POST at all.

POST["letters"] = 3
POST["submit"] = Upload

FILES["file"] = Array
FILES["file"]["name"] = ohio.jpg
FILES["file"]["type"] = image/jpeg
FILES["file"]["tmp_name"] = /tmp/php2Rq5Zw
FILES["file"]["error"] = 0
FILES["file"]["size"] = 51711

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.