Search code examples
phpmailer

Automatically add attachmends based on input field


I would like to know if there is a way to automatically add attachments in my PHPMailer script based on the value of input field.

Example: I have a folder named Stackoverflow.com on my desktop and I would like to add all the attachments from that folder as soon as I type in Stackoverflow.com in my subject input.

enter image description here


Solution

  • No. A script running in a web browser has no direct access to your local files. Many years ago browsers used to allow this, but it (unsurprisingly) turned out to be catastrophically bad from a security perspective. You can select multiple files yourself via a normal file input, but it is up to you to select them, not the code running in the page. Also, this has nothing to do with PHPMailer.