AARA Posted September 1, 2009 Report Share Posted September 1, 2009 Hello Friends ! I am new in php. Can anyone tell me It is possible to use uploaded_file function and use that uploaded image as attachment ! $Sid = md5(uniqid(time())); $header = "MIME-Version: 1.0\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$Sid."\"\n\n"; $header .= "This is a multi-part message in MIME format.\n"; $header .= "--".$Sid."\n"; $header .= "Content-type: text/html; charset=windows-874\n"; // or UTF-8 // $header .= "Content-Transfer-Encoding: 7bit\n\n"; $header .= $emailtext."\n\n"; if($_FILES['upload']['name'] != "") { $FilesName = $_FILES["upload"]["name"]; $upload_Temp = $_FILES["upload"]["tmp_name"]; $Content = chunk_split(base64_encode(file_get_contents($_FILES['upload']['tmp_name']))); $header .= "--".$Sid."\n"; $header .= "Content-Type: multipart/mixed; name=\"".$upload_Name."\"\n"; $header .= "Content-Transfer-Encoding: base64\n"; $header .= "Content-Disposition: attachment; filename=\"".$upload_Name."\"\n\n"; $header .= $Content."\n\n"; // upload image $uploadFile = "uploads/".$FilesName ; @move_uploaded_file( $upload_Temp , $uploadFile); chmod($uploadFile, 0644); }@mail($email, $subject ,$emailtext ,header ) ;Aara Link to comment Share on other sites More sharing options...
justsomeguy Posted September 1, 2009 Report Share Posted September 1, 2009 (edited) Yes, it's possible. You're not keeping track of variable names in your code though, you're trying to use things that are undefined. It shouldn't be necessary to move the uploaded file either, unless you want to save it. Also, all headers need to be separated with \r\n, not just \n or \n\n. Edited September 1, 2009 by justsomeguy Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now