• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 619
  • Last Modified:


Hello, I'm using PHPMailer-FE 4.0.6 to create a form where the user can upload multiple files. The form itself works and e-mails me successfully with proper error checking.

However, the user is able to upload files of any extension and they will attach and be sent with the e-mail. I tried setting the following line in form.config.php to no avail
$_POST['allowedFileTypes']        = 'pdf|jpg|jpeg|png|gif|zip';

Doing some searches on Google proved unsuccessful. Played around with the code in phpmailer-fe.php as well. Any ideas on what has to change in the default phpmailer-fe.php code to allow only certain file extensions to be attached/uploaded? Or am I missing something else.

Thanks in advance for any help!
2 Solutions
Loganathan NatarajanLAMP DeveloperCommented:
Other wise, try to put check point before upload, like,

if($value != "image/jpeg" AND $value != "image/pjpeg" AND $value != "")
exit('Sorry , current format is <b>'.($value).'</b> ,only Jpeg or jpg are allowed.') ;
First, this maybe a stupid question, but it has to be asked first
Did you make sure you uncommented the line:
$_POST['allowedFileTypes'] = .....

By default, it is commented out in the config files.

Second, you have to uncomment this line in several config files if you are using them, form.config.php, default.config.php, contactus.config.php, etc. I did a global find in my php editor to find these, and there may be more.
aaron248Author Commented:
I didn't even think to look default.config.php. I had it already uncommented in form.config.php. Doing that and adding the exit() statement did the trick. Thanks guys for the help!


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now