Posted: Mon Nov 08, 2004 4:43 pm Post subject: Emailform with attachment
I want to create a form which sends an email to an account. Creating this isnt the hard part, its trying to insert an attachment.
I created a form file with all needed attributes and so <input type="file" name="imgfile"> to upload an image.
My process form looks like this and works perfectly with only one problem. The image isnt attached, I only get to see its location an my PC.
Code:
<?php
// get posted data into local variables
$EmailFrom = Trim($_POST[EmailFrom]);
$EmailTo = "emailadres";
$Subject = Trim($_POST[Subject]);
$Naam = Trim($_POST[Naam]);
$imgfile = Trim($_POST[imgfile]);
// validation
$validationOK=true;
if (Trim($EmailFrom)=="" OR Trim($_POST[Subject])=="" OR $Naam = Trim($_POST[Naam])=="" OR $imgfile = Trim($_POST[imgfile])=="") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">";
exit;
}
// prepare email body text
$Body = "";
$Body .= "$Naam ";
$Body .= "zou graag zijn evenement $Subject in de kijker plaatsen";
$Body .= "\n";
$Body .= "Hij geeft hiervoor $Prijs";
$Body .= "\n";
$Body .= "$imgfile";
$Body .= "\n";
Joined: 02 May 2004 Posts: 5915 Location: toronto, canada
Posted: Mon Nov 08, 2004 6:50 pm Post subject:
The email is sent from the serverl. Any file to be attached to the email needs to be on the server as well, so you need to upload the file, send the email and then delete the file, if you want to. _________________ Lostboy
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum