whoknows361
Technical User
Hello all - I am new to php and am have created a flash file which uploads an image file to the server using the following php code:
Now this works correctly and file is uploaded. Now I wanted the php code to automatically email this pic to an email address.
My typical php code for email sending is:
I have attempted numerous times. but how do I combine the two so that my attachment will be emailed. Thanks so much for you help.
Jonathan
Code:
<?php
//create the directory if doesn't exists (should have write permissons)
if(!is_dir("./files")) mkdir("./files", 0755);
//move the uploaded file
move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$_FILES['Filedata']['name']);
chmod("./files/".$_FILES['Filedata']['name'], 0777);
?>
Now this works correctly and file is uploaded. Now I wanted the php code to automatically email this pic to an email address.
My typical php code for email sending is:
Code:
<?
if(!empty($_POST['sender_mail'])
|| !empty($_POST['sender_message'])
|| !empty($_POST['sender_subject'])
|| !empty($_POST['sender_name'])){
$to = "myemail@myemail.com"; // replace with your mail address
$s_name = $_POST['sender_name'];
$s_mail = $_POST['sender_mail'];
$subject = stripslashes($_POST['sender_subject']);
$body = stripslashes($_POST['sender_message']);
$body .= "\n\n---------------------------\n";
$body .= "Mail sent by: $s_name <$s_mail>\n";
$header = "From: $s_name <$s_mail>\n";
$header .= "Reply-To: $s_name <$s_mail>\n";
$header .= "X-Mailer: PHP/" . phpversion() . "\n";
$header .= "X-Priority: 1";
if(@mail($to, $subject, $body, $header)) {
echo "output=sent";
} else {
echo "output=error"; }
} else {
echo "output=error";}
?>
I have attempted numerous times. but how do I combine the two so that my attachment will be emailed. Thanks so much for you help.
Jonathan