Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8689615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:41:30+00:00 2026-06-12T23:41:30+00:00

I am implementing basic email capabilities for administrators on my site. They can set

  • 0

I am implementing basic email capabilities for administrators on my site. They can set the subject, content, etc and then send out the mail to specified recipients. The problem I’m having is with the attachments. They should be able to select multiple files that is already on the webserver (public_html/fileuploads/myfile.pdf for example).

If it cannot be attached from the webserver, then I need to at least implement a way they can attach multiple files from their PC. Currently I’m using Swiftmailer and it accepts attachments like this:

$message->attach(Swift_Attachment::fromPath('/path/to/file.pdf'));

So I need the user to be able to select multiple files. This I can accomplish with:

<input type="file" name="attachment[]" multiple/>

But now I don’t know how to get the full path of each selected file, and then add each file as an attachment. It should be submitted from the HTML to my mailer.php page.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:41:31+00:00Added an answer on June 12, 2026 at 11:41 pm
    // first get a list of the attachments
    $attachments_dir = 'public_html/fileuploads';
    $attachments = glob("$attachments_dir/*.pdf");
    
    // then put them into the form
    foreach ($attachments as $attachment) {
      echo '<input type="checkbox" name="attachments[]" value="',$attachment], '">',$attachment,'<br />'; 
     }
    
    
    // then when the form is submitted, use them
    $selected_attachments = $_POST['attachments'];
    foreach ($selected_attachments as $attachment) {
      $message->attach(Swift_Attachment::fromPath($attachment));
    }
    

    Keep in mind while this shows the process you want to go through it is not very secure.
    Someone could change the attachment to /root/secretpasswords.txt for example and you could attach something not expected.

    If all the attachments are in a single directory only, you could just use the filename part rather then the path/filename in the submission form, but this should be enough to get you started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at a tutorial for asp.net mvc here on the asp site: http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-basic-crud-functionality-with-the-entity-framework-in-asp-net-mvc-application
I'm implementing a basic search feature for a site I'm working on. The cleanest
I'm implementing some basic data structures in C and I found out that if
I am currently implementing a basic raytracer in c++. Works pretty well so far,
I am implementing a basic board game in Java and that I am having
I'm trying to grasp higher-order-polymophism in scala by implementing a very basic interface that
When implementing the INotifyPropertyChanged interface in its most basic form, most people seem to
I used this tutorial to create a basic Javascript function for implementing change during
I am implementing listview with 2 textviews , and for reference used Basic Layout
For a particular piece of homework, I'm implementing a basic data storage system using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.