PHP Email & Form & Image

I’m having difficulty loading an image straight from a form to an email. I don’t want to save it anywhere, only resize it to a fairly easily email size. Then I’d like to simply have it pulled into the email with the rest of the form. Any way to do that? I have read in my manual as well as googled it but no help. Thanks.

I would even consider using some javascript if necessary. I just don’t want to handle it with a database.

Here is the portion of the html/php form:
[php]

Image:

[/php]

And here is associated action on the php upload/email form–which doesn’t work:

[php] ‘picture’ => !empty($_POST[“picture”]) ? $_POST[“picture”]
$msg .= "picture: " . $form[‘picture’];
//and of course the email part, which seems irrelevant to post here. Thanks.
[/php]

Here’s a tutorial on how to do it with phpmailer.

http://www.computersneaker.com/send-email-using-phpmailer/

Yes, and thanks. I saw some like that. I can do it as an attachment. I just wonder if I can do it with the image inside the email.

That’s called “Embedding an Image”, I’ve done it before with PHPList, someone posted a modification to allow it to happen.

I’m not sure if this is the one I used in the past, it’s been so long since I made those modifications…

But read through this thread, it’s 6 pages long and has code samples.

http://forums.phplist.com/viewtopic.php?f=7&t=10082

I actually tried the one with attachments…I can handle attachments. But the code won’t work. Don’t know where to find the class.phpmailer.php

???

Looking in manual now…looks like mail() might be better?

Thx

You can get phpmailer from the official github

You could use base64-encoded images, but most users would still have to choose to “display images” in order to see them.

Here is what I tried without phpmailer. Mail sends but no image. Seems like there is an issue with the file name but I can’t see it.

Form portion:

[php]

Image of vehicle: <?php $allowedExts = array("gif", "jpeg", "jpg", "png"); $temp = explode(".", $_FILES["file"]["name"]); $extension = end($temp); if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/jpg") || ($_FILES["file"]["type"] == "image/pjpeg") || ($_FILES["file"]["type"] == "image/x-png") || ($_FILES["file"]["type"] == "image/png")) && ($_FILES["file"]["size"] < 20000) && in_array($extension, $allowedExts)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "
"; } else { echo "Upload: " . $_FILES["file"]["name"] . "
"; echo "Type: " . $_FILES["file"]["type"] . "
"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB
"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } } else { echo "Invalid file"; } ?>

[/php]

Send portion:

[php]‘picture’ => !empty($_POST[“picture”]) ? $_POST[“picture”] : $emptyText

);[/php]

and

[php] $msg .= "picture: " . $form[‘picture’];[/php]

I’d settle for adding as attachment at this point…but can’t get it to ‘attach’ or upload. Thanks.

Sponsor our Newsletter | Privacy Policy | Terms of Service