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; } ?> Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.