ajax - Sending an image as attachment in a php form -


i have php form, i'm trying image attachment, did fixing code 1. i'm not sure if send image (because had problams it).. 2. problam noting shown in page when open in server index.php not button...

here code:

<?php  include_once("functions.php"); // process $action = isset($_post["action"]) ? $_post["action"] : ""; if (empty($action))  {     // send contact form html     $output = "<form action='#' style='display:none'>                <input type='file' id='image' name='image' maxlength=50>"; }  require("class.phpmailer.php"); $email_to = "someone@gmail.com"; // 1 recieves email $email_from = "someone@someone.net"; $dir = "uploads/$filename"; chmod("uploads",0777);   function uploadimage($image) {     if ((($_files["image"]["type"] == "image/gif")     || ($_files["image"]["type"] == "image/jpeg")     || ($_files["image"]["type"] == "image/pjpeg")     || ($_files["image"]["type"] == "image/jpg")     || ($_files["image"]["type"] == "image/png"))     && ($_files["image"]["size"] < 2097152)     && (strlen($_files["image"]["name"]) < 51))     {         if ($_files["image"]["error"] > 0)         {             echo "return code: " . $_files["image"]["error"];         }         else         {             echo "upload: " . $_files["image"]["name"] . "<br />";             echo "type: " . $_files["image"]["type"] . "<br />";             echo "size: " . ($_files["image"]["size"] / 1024) . " kb<br />";             echo "temp file: " . $_files["image"]["tmp_name"] . "<br />";              if (file_exists("images/" . $_files["image"]["name"]))             {                 echo $_files["image"]["name"] . " exists. ";             }             else             {                 move_uploaded_file($_files["image"]["tmp_name"],                     "images/" . $_files["image"]["name"]);             }         }     }     else     {         echo "invalid file";     } $filename = $_files["image"]["type"]; $dir = "uploads/$filename"; chmod("uploads",0777); $success = copy($_files[images][tmp_name], $dir); if ($success)      {     echo " files uploaded successfully<br>";     sendit();     } }//end of upload func'   function sendit() { // global $attachments,$email_to,$email_msg,$email_subject,$email_from;  $mail = new phpmailer(); $mail->issmtp();// send via smtp $mail->host = "localhost"; // smtp servers $mail->smtpauth = false; // turn on/off smtp authentication $mail->from = $email_from; $mail->addaddress($email_to); $mail->addreplyto($email_from); $mail->wordwrap = 50;// set word wrap //now attach files submitted $mail->addattachment("uploads"."/".$_files["image"]["type"]);  $mail->ishtml(false);// send html }   ?> 

thank in advance!

to join image e-mail, need create mime e-mail, simple mail() won't suffice. gazillions of modules handle that, pear's mail_mime typically available in environment.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -