Is it possible to send attachment via wp_mail, using temporary file, instad of uploading them to any actual folder on server?

For example:

<input type="file" name="file">

$attachment[] = $_FILES['file']['name'];



The filenames in the $attachments attribute have to be filesystem paths.

How can i get the path for temporary file (if this is possible)?

1 Answer 1


Yes. it's possible. Attachment file contents are taken by wp_mail call.

Use $_FILES['file']['tmp_name'] for filename

  • The file extension and content is not correct. Does not work. Jul 17, 2020 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.