bpdp
05-06-2007, 07:31 PM
Hello,
I'm very new to PHP so bare with me. I have a flash application that allows a user to upload an image. on the flash side there is also a form that lets the user enter their name, email address and a message. this info gets emailed to me. Everything works but I would like to have the url for the image that they uploaded sent in the body of the email along with their message. I thought this would be easy. But I've had no luck. I feel like I've tried everything I know (which isn't all that much). Just wondering someone out there could help me out.
<?php
if ($_FILES['Filedata']['name']) {
$ran = rand();
$ran2 = $ran."_";
$uploadDir = "user_img/" . $ran2;
$uploadFile = $uploadDir . basename($_FILES['Filedata']['name']);
// replace any spaces in file name
$uploadFile = str_replace (' ', '', $uploadFile);
move_uploaded_file($_FILES['Filedata']['tmp_name'],$uploadFile);
echo " ";
}
// email
$sendTo = "email at someemail.com";
$subject = "My Email Subject";
$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$message = "Message: \r\n" . $_POST["message"];
mail($sendTo, $subject, $message, $headers);
?>
When I try something like:
$message = "Message: \r\n" . $_POST["message"] . $uploadFile;
I get an email with the url, but none of the other info (no subject, sendTo, headers, or the message)... the url is the only thing that is sent. I've tried a bunch of other things too - and I either get everything but the url, or nothing but the url... Please help me out - thanks!
I'm very new to PHP so bare with me. I have a flash application that allows a user to upload an image. on the flash side there is also a form that lets the user enter their name, email address and a message. this info gets emailed to me. Everything works but I would like to have the url for the image that they uploaded sent in the body of the email along with their message. I thought this would be easy. But I've had no luck. I feel like I've tried everything I know (which isn't all that much). Just wondering someone out there could help me out.
<?php
if ($_FILES['Filedata']['name']) {
$ran = rand();
$ran2 = $ran."_";
$uploadDir = "user_img/" . $ran2;
$uploadFile = $uploadDir . basename($_FILES['Filedata']['name']);
// replace any spaces in file name
$uploadFile = str_replace (' ', '', $uploadFile);
move_uploaded_file($_FILES['Filedata']['tmp_name'],$uploadFile);
echo " ";
}
$sendTo = "email at someemail.com";
$subject = "My Email Subject";
$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$message = "Message: \r\n" . $_POST["message"];
mail($sendTo, $subject, $message, $headers);
?>
When I try something like:
$message = "Message: \r\n" . $_POST["message"] . $uploadFile;
I get an email with the url, but none of the other info (no subject, sendTo, headers, or the message)... the url is the only thing that is sent. I've tried a bunch of other things too - and I either get everything but the url, or nothing but the url... Please help me out - thanks!