Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok to attach Files the User first needs an Upload-Form</p> <pre><code>&lt;form enctype="multipart/form-data" action="uploader.php" method="POST"&gt; &lt;input type="hidden" name="MAX_FILE_SIZE" value="100000" /&gt; Choose a file to upload: &lt;input name="uploadedfile" type="file" /&gt;&lt;br /&gt; &lt;input type="submit" value="Upload File" /&gt; &lt;/form&gt; </code></pre> <p>to save the File in PHP do something like this</p> <pre><code>$target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else{ echo "There was an error uploading the file, please try again!"; } </code></pre> <p>So now you have the Files to send as Attachment, rewrite your script to a function that can handle multiple attachments...</p> <p>something like this should work...</p> <pre><code>&lt;?php function sendMail($to, $from, $subject, $message, $attachments){ $headers = "From: $from"; // 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/plain; 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($attachments);$x++){ $file = fopen($attachments[$x],"rb"); $data = fread($file,attachmentsize($attachments[$x])); fclose($file); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$attachments[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$attachments[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; $message .= "--{$mime_boundary}\n"; } // send $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;"; } } ?&gt; </code></pre> <p>I have not tested this code but it should push you in the right direction ;-)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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