html - PHP mailer not working for attachments? -


i stucked while giving file upload path, have html file input name uploadfile , using phpmailer() send attachement. please me need php developers support. here code tell me why getting not access file error. , email not having attachment message coming.

<div class="field"> <label for="browse">file upload: <span class="required">*</span></label> <div class="inputs"> <input name="uploadedfile" id="uploadedfile" type="file" style=" height: 37px;" name="max_file_size" value="100000" /> </div> </div>   //form fields $name = $_post["name"];     $email = $_post["email"];     $phone = $_post["phone"];     $subject = $_post["subject"];     $message = $_post["message"];     $verify = isset($_post["verify"]) ? $_post["verify"] : "";     $path = $_files["uploadedfile"]["name"];     echo $path;     $encoding = 'base64';     $type = 'application/octet-stream';  $objmail->from = $email;             $objmail->fromname = $name;             $objmail->addaddress($toaddress, $toname);               $objmail->addreplyto($email, $name);             $objmail->subject = $email_subject;             $objmail->msghtml($email_body);              $objmail->addattachment($path,$encoding,$type);             if(!$objmail->send()) {                 $error = "message sending error: ".$objmail->errorinfo;                          }                            } 

two problems:

first:

$path = $_files["uploadedfile"]["name"]; $objmail->addattachment($path,$encoding,$type); 

$path going name of file on client machine. has absolutely nothing temporary file php stores in, listed in ['tmp_name'].

second:

you don't validate upload occurred @ all, , assuming succeeded. @ minimum, need have

if ($_files['uploadedfile']['error'] === upload_err_ok) {    $objmail->addattachment(        $_files['uploadedfile']['tmp_name'],  // temp location on server        $_files['uploadedfile']['name'],     // name appears in email        'base64',        $_files['uploadedfile']['type']   // mime type provided uploader    ); } 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -