Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

emailing file as attachement from form submission

Hello.

I use the following to process form submissions.
It uploads the file submitted to the server and sends a notice to the webmaster.

I don't want the file to be uploaded.  Instead, I want the file to be emailed to the webmaster as an attachement, along with the notice.

How can this be done?

Thanks!


-------------------------------------------------------------------------
<?php
ob_start();
include("../lib/global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
$file2upload=$HTTP_POST_FILES["file2upload"];
if(!is_uploaded_file($HTTP_POST_FILES["file2upload"]["tmp_name"])){
$error.="<li>The file, ".$HTTP_POST_FILES["file2upload"]["name"].", was not uploaded!";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$HTTP_POST_FILES["file2upload"]["name"];
$image_list[0] = $image_part;
copy($HTTP_POST_FILES["file2upload"]["tmp_name"], "files/".$image_part);
$message="file2upload: ".$where_form_is."files/".$image_list[0]."
";
$message = stripslashes($message);
@mail("me@myemail.com","Form Submitted at your website",$message,"From: me@myemail.com");}
header("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . $relative_url);
ob_end_flush();
?>
-------------------------------------------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of Diablo84
Diablo84

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Diablo84
Diablo84

Please see this thread for examples of use: http:Q_21141127.html
if you need it.