tomtallis Posted June 23, 2009 Share Posted June 23, 2009 Hi all, I'm quite new to PHP, so I hope this isn't too silly of a question: I have a script to upload a sound file and I'm trying to get information from the html form into a php-generated email so that the owner can see the file attributes. The user enters their email, name and file. I can get the email and name from the form, but I can't get the file information in the email, but I can get it to display on the php page. So far I have: <?php $to = "[email protected]"; $subject = "Upload Alert"; $message = $_REQUEST["name"]; XXXXXXXX; XXXXXXXX; $from = $_REQUEST["email"]; $headers = "From: $from"; if ((($_FILES["file"]["type"] == "audio/x-ms-wma") || ($_FILES["file"]["type"] == "audio/wav") || ($_FILES["file"]["type"] == "audio/mpeg"))) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; mail($to,$subject,$message,$headers); echo "Mail Sent." . "<br />"; if (file_exists("bucket/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "bucket/" . $_FILES["file"]["name"]); echo "Stored in: " . "bucket/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> What I want to do is put the information from these echos: echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; into the body of the email, along with the user's name and email address. Thanks Link to comment https://forums.phpfreaks.com/topic/163314-html-form-to-email/ Share on other sites More sharing options...
pkedpker Posted June 23, 2009 Share Posted June 23, 2009 replace echo with a string <?php //colors $message .= "Upload: " . $_FILES["file"]["name"] . "<br />"; $message .= "Type: " . $_FILES["file"]["type"] . "<br />"; $message .= "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; $message .= "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; ?> Link to comment https://forums.phpfreaks.com/topic/163314-html-form-to-email/#findComment-861676 Share on other sites More sharing options...
tomtallis Posted June 23, 2009 Author Share Posted June 23, 2009 Beautiful, works like a charm, thanks Link to comment https://forums.phpfreaks.com/topic/163314-html-form-to-email/#findComment-861684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.