email attachments - PHPMailer - How do I unlink files in temp dir.? -


i looping through files array shown in middle chunk of code, rest of code better context.

$email = new phpmailer(); $email->from      = 'john@example.com'; $email->fromname  = 'john doe'; $email->subject   = $name_talent;                         $body = '<strong>address</strong> : ' .$address_talent.'<br><br>';  if ($_files) {     foreach ($_files $file => $array) {     $tmp_path = $_files[$file]['tmp_name'];     $tmp_name = basename($_files[$file]['name']);     $email->addattachment($tmp_path, $tmp_name);     } }  $email->body = $body; $email->ishtml(true);  $email->addaddress( '#####@gmail.com' ); $email->send(); 

this sends attachments values in $body well. now, unlink files either after mail sent or attachments successful. inspired from answer, if below, no files attached , variables set $body eg. $address_talent do not appear in email.

if ($_files) {     foreach ($_files $file => $array) {     $tmp_path = $_files[$file]['tmp_name'];     $tmp_name = basename($_files[$file]['name']);          if($email->addattachment($tmp_path, $tmp_name)){          unlink("$tmp_path");          }     } } 


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -