SilentQ-noob- Posted October 1, 2007 Share Posted October 1, 2007 HI, I use e-mail forms on my site frequently for user feedback, and it works great. However; now I for one of the forms I want users to upload a picture (which will send to my email ) as well. I'm still pretty new to this so I'm not quite sure how to go about it. This is what I have now: <? $email = $_POST['email']; $image = $_FILES['fupload']['tmp']; $to = "myemail@gmaildotcom"; if($_FILES['fupload']['type'] == "image/jpg" ) { mail($to, "Email: $email" , " Picture: $image" ); } ?> <form enctype="multi-part/form-data" action="<? print $_SERVER['PHP_SELF'] ?>" method="post"> <p> Email:<input type="text" value="<? echo $email ?>" /> <input type="hidden" name="MAX_FILE_SIZE" value="102400" /> <input type="file" name="fupload" /><br /> <input type="submit" value="Send" /> </form> I'm pretty sure what I have to do is save the images temporarily in a folder somewhere on my server, and then send the image from there, or maybe not? Any help would be greatly appreciated! looking forward to feedback, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/71405-attach-image-to-email/ Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 you've got to correctly format your email with proper MIME headers to attach any kind of file. here's some info: http://www.codewalkers.com/c/a/Email-Code/PHP-Email-Attachment-v1/ Quote Link to comment https://forums.phpfreaks.com/topic/71405-attach-image-to-email/#findComment-359386 Share on other sites More sharing options...
SilentQ-noob- Posted October 1, 2007 Author Share Posted October 1, 2007 That kind of does what I want. How could I take that code and change it so that the user has one of those, "browse..." buttons, and can then send their own picture? Quote Link to comment https://forums.phpfreaks.com/topic/71405-attach-image-to-email/#findComment-359492 Share on other sites More sharing options...
LemonInflux Posted October 1, 2007 Share Posted October 1, 2007 that would be on the page before. <input type="file" name="image_file"> Quote Link to comment https://forums.phpfreaks.com/topic/71405-attach-image-to-email/#findComment-359494 Share on other sites More sharing options...
SilentQ-noob- Posted October 1, 2007 Author Share Posted October 1, 2007 I'm sorry you mean like another step in this page: http://www.codewalkers.com/c/a/Email-Code/PHP-Email-Attachment-v1/ ...? Quote Link to comment https://forums.phpfreaks.com/topic/71405-attach-image-to-email/#findComment-359522 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.