PHP Classes

Save attachments with names

Recommend this page to a friend!

      POP3 e-mail client  >  All threads  >  Save attachments with names  >  (Un) Subscribe thread alerts  
Subject:Save attachments with names
Summary:Save only attachments to disk?
Messages:2
Author:Allen Swope
Date:2010-11-02 21:32:04
Update:2010-11-02 21:59:40
 

  1. Save attachments with names   Reply   Report abuse  
Picture of Allen Swope Allen Swope - 2010-11-02 21:32:04
Has anyone written a function or wrapper that would allow me to save the email attachments (with original filename) to disk?

I found the author's suggestion to turn on save body parts, but that just chunks the body and any attachments to disk with numeric filenames.

I want to be able to save only body parts of disposition "attachment" and preserve the original filename.

Anyone?

  2. Re: Save attachments with names   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2010-11-02 21:59:40 - In reply to message 1 from Allen Swope
The class does not use the original file names for security reasons. Somebody can send you a message with an attachment with dangerous file name like .htaccess and eventually work around some protections on your system by changing configuration files.

Another problem is an attacker specifying the same file name in multiple attachments.

The class saves files with numeric file names because those are guaranteed to be unique.

The class also provides you the original file names in the parsing results. It is up to your application to use those file names in a secure way.