Hello,
I have been testing a very simple PHP file that "should" send an file attachment in an email. However, it sends an email without the file attachment. Can anyone tell me where I went wrong. I have copied the code below. The .htm file I am working with is called
http://www.knowtypos.com/show_upload.htm
Thank you in advance for your time.
<?
// if $FILES['img1'] isn't empty, try to copy the file
if ($FILES['img1'] != "") {
// copy the file to a directory or
//die and print an error message
// NOTE! if you're on a Windows machine,
// use Windows pathnames, like so:
// copy($FILES[img1][tmp_name], "C:\some\directory\path\".$POST[img1_name]);
copy($FILES['img1']['tmp_name'], "/mmm1102/web/knowt2/".$FILES['img1']['name'])
or die("Couldn't copy the file!"); } else
{
// if $_FILES['img1'] was empty, die and let us know why
die("No input file specified"); }
if ($_FILES['img1'] != "") {
copy($FILES['img1']['tmp_name'], "/mmm1102/web/knowt2/".$FILES['img1']['name'])
or die("Couldn't copy the file!"); } else { die("No input file specified");}
unlink($img1);
$to = "Rich <sockit@knowtypos.com>";
$subject = "Project Request Form";
mail($to, $subject, $_FILES);
?>
<head>
<title>Successful File Upload!</title>
</head>
<body>
<h1>Success!</h1>
<P>You sent: <? echo $FILES['img1']['name'] ?>, a <? echo $FILES['img1']['size'];
?> byte file with a mime type of <? echo $_FILES['img1']['type']; ?>.</p>
</body>