Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to remove directory name from the attachment name in php
    text
    copied!<p>i have a small issue. i had upload a screen shot of a email that has an attachment sent by using php.but in the attachment name there is the directory name as "upload./" i want to remove that part. how can i do that? </p> <p>Thank you.<img src="https://i.stack.imgur.com/m1GSN.png" alt="enter image description here"></p> <pre><code>$message = $mes; echo $message; //echo $message; $subject = $coursetitle; $headers .= 'Cc: gayani@amdt.lk' . "\r\n"; ini_set("SMTP", "mail.amdt.lk"); ini_set("sendmail_from", "info@amdt.lk"); // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // multipart boundary $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $message .= "--{$mime_boundary}\n"; // preparing attachments for($x=0;$x&lt;count($files);$x++){ $file = fopen($dir.$files[$x],"rb"); $data = fread($file,filesize($dir.$files[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$dir.$files[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$dir.$files[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; $message .= "--{$mime_boundary}\n"; } // send //echo $message; $ok = mail($to, $subject, $message, $headers); if ($ok) { echo "&lt;p&gt;mail sent to $to!&lt;/p&gt;"; } else { echo "&lt;p&gt;mail could not be sent!&lt;/p&gt;"; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload