Reputation: 119
How to send file by mail()
function of PHP as the attachment without uploading file to sever (just after submiting the form, using $_FILES
array)?
Upvotes: 0
Views: 3106
Reputation: 7
get the file: $attachment = $_FILES['attachment']['tmp_name'];
get the file name: $attachment_name = $_FILES['attachment']['name'];
add the file to mail: $mail->addAttachment($attachment,$attachment_name);
Upvotes: 0
Reputation: 324780
If you're using the $_FILES
array, the file is already uploaded to the server (usually in /tmp
), so your question doesn't really make sense.
I understand what you mean, though. You want to send it as an attachment without moving it to a more permanent location. This can be done easily using
file_get_contents($_FILES['attachment']['tmp_name']);
.
Upvotes: 5