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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.