How I can do:
1. Upload multiple files into folder.
2. Then fetch those files that had saved in a folder. (I have to upload once but fetch again and again )
3. and Then attach those files one by one and send to specified email/s.

Dani AI

Generated

Brief plan: upload files once into a secured server folder, record each file’s metadata (original name, stored name/path, size, MIME, upload time) in a small lookup (DB, SQLite or CSV), then when you need to resend fetch that list and either (a) email the files as attachments or (b) send download links. As noted, links are preferable for large files; and ’s advice to keep the storage outside the web root is important for safety.

Practical implementation notes and pitfalls to avoid:

  • Give every file a safe, unique stored name (eg. uniqid() + original basename) and keep the original name in metadata to avoid collisions and path traversal.
  • Verify uploaded content by MIME (fileinfo) and an allowlist of extensions; reject or quarantine unknown/ executable types.
  • Store files with restrictive permissions and an owner/group that the web process controls (avoid 0777; prefer 0750/0640 depending on your server).
  • Don’t assume email can carry large payloads — many providers cap attachments (10–25MB). Zip multiple files server-side or prefer secure download links when totals are bigger.

Example sending workflow (use a mail library and SMTP; do sending in a background job for many recipients):

// pseudo/concise example using PHPMailer
$mail = new PHPMailer(true);
$mail->isSMTP(); $mail->Host='smtp.example.com'; $mail->SMTPAuth=true;
$mail->Username='user'; $mail->Password='pass';
$mail->setFrom('me@example.com','Me'); $mail->addAddress($to);
foreach (glob('/path/to/secure/uploads/*') as $file) {
    $mail->addAttachment($file); // PHPMailer streams file from disk
}
$mail->Subject = 'Files';
$mail->Body = 'Attached files.';
$mail->send();

Quick checklist before you go live: increase upload_max_filesize/post_max_size and max_file_uploads if needed; monitor max_execution_time and memory usage; log upload/send failures; implement a queue or cron-driven sender for bulk jobs; test with small files first.

Recommended Answers

All 2 Replies

How these file are uploaded to server? FTP, WebDav, forms?
How you have to send the files? As attachments or as download links? Second option, if you can, is preferable.

Basically anyway, if you want to submit by forms, you have to build a proper form to upload files, use the relative array $_FILES to check, rename and move them to a directory (throught move_uploaded_file()) and finally use mail() or PEAR mail() which is better for long running loops:

- http://php.net/manual/en/reserved.variables.files.php
- http://php.net/manual/en/function.move-uploaded-file.php
- http://php.net/manual/en/function.mail.php
- http://pear.php.net/package/Mail/

Both procedures: upload and mail attachments, have been discussed in the forum.
If the email list is fixed I suggest you to build an array and use that instead of a database connection, so you can speed up and limit hits on database.

things you need to know

1. I use this link to upload files http://www.tizag.com/phpT/fileupload.php, make sure the dump folder is outside www root folder to make it more secure and set its permission using chmod 775 command.

2. you may use phpmailer or pear to send and attached files from your dump folder.


hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.