clausowitz Posted July 14, 2011 Share Posted July 14, 2011 Hi, I use a page to post a message on a bulletin board. When I send the POST to the next page which deals with the process of saving the message, two variables get recognized but the third not. $name=$_POST['name']; and $message=$_POST['message']; get recognized but $image=$_POST['image']; not. and I get the famous error Notice: Undefined index: image. I don't see the difference between them. <?php $pageDisplay = '<form name="new_message" enctype="multipart/form-data" action="news/post.php" method="post"><p>Welcome <b>'. $logOptions_username . '</b> post your message here.<br></p> <input type="hidden" name="post" value="yes"> <p> Heading<br> <input type="text" name="name" size="50"> </p> <p> Message<br> <textarea name="message" rows="5" cols="50"></textarea> </p> <p> Picture<br> <input name="image" type="file"> [under construction] </p> <p> <input type="submit" value=\'Post Message\'> <input type="reset" value="Reset"> </p> </form>'; ?> Marco Quote Link to comment https://forums.phpfreaks.com/topic/241974-two-post-variables-get-recognized-the-third-not/ Share on other sites More sharing options...
Lyleyboy Posted July 14, 2011 Share Posted July 14, 2011 The thing is when your returning an image there is no value so nothing will show. Quote Link to comment https://forums.phpfreaks.com/topic/241974-two-post-variables-get-recognized-the-third-not/#findComment-1242645 Share on other sites More sharing options...
PFMaBiSmAd Posted July 14, 2011 Share Posted July 14, 2011 The uploaded file information will be available in the $_FILES array, not the $_POST array. I recommend that you read the file upload handling section of the php documentation - http://us2.php.net/manual/en/features.file-upload.php Quote Link to comment https://forums.phpfreaks.com/topic/241974-two-post-variables-get-recognized-the-third-not/#findComment-1242647 Share on other sites More sharing options...
clausowitz Posted July 14, 2011 Author Share Posted July 14, 2011 But at that point the file still has to be uploaded. Just the path has been defined. So I don't think there will be anything in the array. Could I change the image into a string representing the path and send that to Post.php? Marco Quote Link to comment https://forums.phpfreaks.com/topic/241974-two-post-variables-get-recognized-the-third-not/#findComment-1242709 Share on other sites More sharing options...
AyKay47 Posted July 14, 2011 Share Posted July 14, 2011 But at that point the file still has to be uploaded. Just the path has been defined. So I don't think there will be anything in the array. Could I change the image into a string representing the path and send that to Post.php? Marco what are you talking about? Any information that is gathered using the "file" type input attribute is stored in the $_FILES array, this include the file name, size, tmp folder that it is stored in, etc... Quote Link to comment https://forums.phpfreaks.com/topic/241974-two-post-variables-get-recognized-the-third-not/#findComment-1242724 Share on other sites More sharing options...
clausowitz Posted July 14, 2011 Author Share Posted July 14, 2011 So I found out. It's working now. I changed the POST for the FILES array. Thanks a lot for pointing me to the right direction. Marco Quote Link to comment https://forums.phpfreaks.com/topic/241974-two-post-variables-get-recognized-the-third-not/#findComment-1242736 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.