aeonsky Posted October 28, 2008 Share Posted October 28, 2008 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 More sharing options...
DarkWater Posted October 28, 2008 Share Posted October 28, 2008 Umm, add a name attribute to the submit button and test that. Link to comment https://forums.phpfreaks.com/topic/130364-solved-_post-not-working-with-_files/#findComment-676233 Share on other sites More sharing options...
aeonsky Posted October 28, 2008 Author Share Posted October 28, 2008 Oh, that works. But I don't get why $_POST['uploadedfile'] doesn't work. Link to comment https://forums.phpfreaks.com/topic/130364-solved-_post-not-working-with-_files/#findComment-676236 Share on other sites More sharing options...
DarkWater Posted October 28, 2008 Share Posted October 28, 2008 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. Link to comment https://forums.phpfreaks.com/topic/130364-solved-_post-not-working-with-_files/#findComment-676239 Share on other sites More sharing options...
aeonsky Posted October 28, 2008 Author Share Posted October 28, 2008 Heh, that makes more or less some sense. Thanks. Link to comment https://forums.phpfreaks.com/topic/130364-solved-_post-not-working-with-_files/#findComment-676241 Share on other sites More sharing options...
Stephen Posted October 28, 2008 Share Posted October 28, 2008 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 https://forums.phpfreaks.com/topic/130364-solved-_post-not-working-with-_files/#findComment-676248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.