Page 1 of 1

email uploaded image

Posted: Tue Nov 08, 2005 3:46 am
by ben_albrechts
Hello,

I now have a form on my site for the clients to fill in all their details aswell as upload an image.
Now I would need for when they click the submit button ,that the information they submitted aswell as the image they uploaded are displayed. AND it also needs to be emailed to me in one email with the uploaded image as an attachement to the email with the details submitted.

How can I do this?

Posted: Tue Nov 08, 2005 3:54 am
by Charles256
go to the php manual, look up file upload and mail.
eh..
http://us2.php.net/features.file-upload
http://us2.php.net/manual/en/function.mail.php
though for mail i recommend using
http://phpmailer.sourceforge.net/

Posted: Tue Nov 08, 2005 6:22 am
by ben_albrechts
Right , i had a look at those links u gave me.
I did know how to email the data that was submitted and how to display it.
But since I added the 'image upload' to my form , it doesn't work anymore.
The image won't display together with the text and the email doesn't include the image either.
:?

Posted: Tue Nov 08, 2005 7:14 am
by Charles256
yeah you gotta do the following on your form...

<form enctype="multipart/form-data"

did you do that?

Posted: Tue Nov 08, 2005 7:44 am
by ben_albrechts
yea i did

Posted: Tue Nov 08, 2005 7:49 am
by Charles256
then post your code so we can see it.

Posted: Tue Nov 08, 2005 11:08 am
by ben_albrechts
The code is rather long as I have about a hundred switch cases in it.
but the problem that i dont understand is. After people click submit , there image should be displayed on the thank you page.
But don't you need to know the url to display and image? I know the folder where the images should be moved to , but if i want to show them , i need to use echo '..... right? but what comes after echo?

Posted: Tue Nov 08, 2005 11:12 am
by Charles256
um.. a simple html img tag:-D

Posted: Tue Nov 08, 2005 11:15 am
by ben_albrechts
yes , but i dont understand. It is so that the image is saved in a folder under the name that it was on the visitor's pc . So it can be anything , how do i make an img tag then that it does show?

Posted: Tue Nov 08, 2005 11:20 am
by Charles256
no.once they upload it it's on your server...and you should know where you placed it..and what you named it....

Posted: Tue Nov 08, 2005 11:51 am
by ben_albrechts
i have this :

Code: Select all

copy ($_FILES['imagefile']['tmp_name'], "files/".$_FILES['imagefile']['name']) 
    or die ("Could not copy");
it copies the image to a folder called files. But it doesnt change the name.
So wot do I put to display this image on the thankyou page?

Argh it's all confusing me way too much lol

Posted: Tue Nov 08, 2005 11:58 am
by Grim...

Code: Select all

echo "<img src="files/".$_FILES['imagefile']['name']." />";

Posted: Wed Nov 09, 2005 11:58 am
by ben_albrechts
if i make a seperate form for the image upload and i put

Code: Select all

copy ($_FILES['imagefile']['tmp_name'], "files/".$_FILES['imagefile']['name']) 
    or die ("Could not copy");
it does work and moves and saves the image in a folder called files

but if i put it in an existing form that also has text input and all , it doesnt work and the image isnt uploaded nor saved in that folder.

Also even if i use a seperate form for the file upload , I can't manage to get the image displayed on the thank you page.
Can anybody please help me?

I also need the image together with the text my users wrote in the form to be emailed to me , and that won't work either

Posted: Wed Nov 09, 2005 6:28 pm
by John Cartwright
Are you sure you are retreiving the file name from the database? I suspect your trying to use the $_FILE array to determine the image name, but the $_FILES information will only exist on the page execution of the upload. Post your code where you are trying to show the image.

Posted: Thu Nov 10, 2005 3:54 am
by ben_albrechts

Code: Select all

echo "<img src="files/".$_FILES['imagefile']['name']." />";