fesan Posted January 31, 2010 Share Posted January 31, 2010 Hello... I have made a form that sends a some text and a picture to a php script. The form posts to itself with [$_SERVER['REQUEST_URI']. The form looks like this: <form method="POST" action="'.$_SERVER['REQUEST_URI'].'"> <label>Bilde: <input type="file" name="image" id="image" /> </label> <br /> <label>comment:<br /> <input name="comment" type="text" id="comment" size="50" /> </label> <input type="Submit" name="Submit" id="Submit" value="Submit" /> <br /> </p> </form> The code that receives the image and the text looks like this: if(isset($_POST['Submit'])) { //Some Size variables for the image and other preparations for the script. if (isset($_FILES['image']['name'])) { //resize and upload the image in two sizes. echo "Done"; } echo "did not receive picture"; } The script stopped working when implementing it to my website. The file is included with a switch in index.php. Does anyone have a clue to why it stopped working? the script fails at the if (isset($_FILES['image']['name'])), so i guess that the picture cant get true somehow. Link to comment https://forums.phpfreaks.com/topic/190438-post-image-with-form/ Share on other sites More sharing options...
jl5501 Posted January 31, 2010 Share Posted January 31, 2010 your form tag should be <form method="POST" action="'.$_SERVER['REQUEST_URI'].'" enctype="multipart/form-data"> Link to comment https://forums.phpfreaks.com/topic/190438-post-image-with-form/#findComment-1004559 Share on other sites More sharing options...
MasterACE14 Posted January 31, 2010 Share Posted January 31, 2010 <form method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>" enctype="multipart/form-data"> Link to comment https://forums.phpfreaks.com/topic/190438-post-image-with-form/#findComment-1004560 Share on other sites More sharing options...
fesan Posted January 31, 2010 Author Share Posted January 31, 2010 Wow... Thanks. I had the enctype="multipart/form-data" in my script but removed it when trying to locate the error. When i added it back now it worked flawless! Thanks guys!! Have a nice Sunday! Link to comment https://forums.phpfreaks.com/topic/190438-post-image-with-form/#findComment-1004568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.