It is currently Sat Feb 04, 2012 3:32 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Emailform with attachment
PostPosted: Mon Nov 08, 2004 5:43 pm 
Offline

Joined: Mon Oct 04, 2004 8:44 pm
Posts: 30
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";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=succes.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.php\">";
}
?>


Any idea´s?

I also tried with $_FILES but that just gave me the location on my server without the file
Code:
$uploaddir = '/path/to/your/image/files/'; // remember the trailing slash!
   $uploadfile = $uploaddir. $_FILES['imgfile'];


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 08, 2004 7:50 pm 
Offline

Joined: Sun May 02, 2004 11:34 pm
Posts: 6498
Location: toronto, canada
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

Cat, the other other white meat

Please read Posting Etiquette before posting

You can always try Google


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  
cron