blink359 Posted April 4, 2010 Share Posted April 4, 2010 Hello i wish to create a form that sends an image as an attachement from the form i have made to the email that i receive from it here is what i have at the moment. <?php // Receiving variables @$pfw_ip= $_SERVER['REMOTE_ADDR']; @$name = addslashes($_GET['name']); @$address = addslashes($_GET['address']); @$county = addslashes($_GET['county']); @$postcode = addslashes($_GET['postcode']); @$phone = addslashes($_GET['phone']); @$email = addslashes($_GET['email']); @$size = addslashes($_GET['size']); @$image_Name = $_FILES['image']['name']; @$image_Size = $_FILES['image']['size']; @$image_Temp = $_FILES['image']['tmp_name']; @$image_Mime_Type = $_FILES['image']['type']; // Validation //Sending Email to form owner $pfw_header = "From: $name\n" . "Reply-To: $name\n"; $pfw_subject = "Order"; $pfw_email_to = "[email protected]"; $pfw_message = "Visitor's IP: $pfw_ip\n" . "name: $name\n" . "address: $address\n" . "county: $county\n" . "postcode: $postcode\n" . "phone: $phone\n" . "email: $email\n" . "size: $size\n" @mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ; echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Order successfully processed we will be contacting you shortly to confrim your order and discuss payment details.</font></p>"); ?> Full Name:<br /> <input type="text" name="name" border="1" /><br /> Address:<br /> <input type="text" name="address" border="1" /><br /> County:<br /> <input type="text" name="county" border="1" /><br /> Post Code:<br /> <input type="text" name="postcode" border="1" /><br /> Phone Number:<br /> <input type="number" name="phone" border="1" /><br /> Paypal Email:<br /> <input type="email" name="email" border="1" /> </p> <p>Size:</p> A3 Approx. 10" x 14" £21.99 <input type="radio" name="size" value="A3"/><br /> A2 Approx. 16" x 20" £25.99 <input type="radio" name="size" value="A2" /><br /> A1 Approx. 20" x 30" £29.99 <input type="radio" name="size" value="A1" /><br /> A0 Approx. 30" x 45" £69.99 <input type="radio" name="size" value="A0" /><br /> <br /> Image:<br /> <input id="file" type="file" name="image"><br /> <input type="submit" /> </p> </form> If anyone can help me by giving me the code or telling me a website that will tell me how to do so would be much appriciated! Thanks, Blink359 Link to comment https://forums.phpfreaks.com/topic/197553-email-form-with-image/ Share on other sites More sharing options...
the182guy Posted April 4, 2010 Share Posted April 4, 2010 The first thing you need to do is write some code so that when the form is submitted, the file gets uploaded to your server and saved in a location of your choice. Here is a tutorial for this: http://www.tizag.com/phpT/fileupload.php Then when you have that working, you can code the part which sends the image as an attachment to the email. Here is an example script for this: http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php#attachment However, it will be easier to just include a link to the image in the email rather than attaching it, or use a HTML email that will show the image in the email by linking to the source image on your server, instead of attaching. Link to comment https://forums.phpfreaks.com/topic/197553-email-form-with-image/#findComment-1036830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.