Help With PHP Email Form – Attaching Files?

Hello
being a newbie in php programming field I would like to ask for assistance with e-mail form and attaching files. I have bought a template for website with included mailer form. The only problem with it is that it only allows to attach jpg files and i need word documents, pdf, and exel files as well as images to be attached and mailed.
Below is the script line from the form. Can someone please advise on how can i modify it in order to have word, exel, pdf and image files arrive to my email. Thank you

<? if($_POST) {
include(‘form_config.php’);
if(eregi(‘.jpg’,$_FILES[image][name])) {
$unid = uniqid();
move_uploaded_file($_FILES[image][tmp_name],’offer_uploads/’.$unid.’.jpg’);
$urla = "http://www.globalmeattraders.com/offer_uploads/$unid.jpg";

The code has been truncated, so it is difficult to tell you exactly what is going on…
But, it seems that the line:

if(eregi(‘.jpg’,$_FILES[image][name]… {

is checking whether the uploaded file is of the type .jpg
Whenever, a file is uploaded, the file info is stored in the $_FILES superglobal. You can access the type of the uploaded file using $_FILES[image][type].

So, in the above mentioned if condition, check what is happening. If it is just checking the file type, you can remove it and your code will allow other file extensions too.

Refer to the following link for more details:

http://www.php.net/manual/en/features.file-upload.php

One Response to “Help With PHP Email Form – Attaching Files?”

  • Archana says:

    The code has been truncated, so it is difficult to tell you exactly what is going on…
    But, it seems that the line:

    if(eregi(‘.jpg’,$_FILES[image][name]… {

    is checking whether the uploaded file is of the type .jpg
    Whenever, a file is uploaded, the file info is stored in the $_FILES superglobal. You can access the type of the uploaded file using $_FILES[image][type].

    So, in the above mentioned if condition, check what is happening. If it is just checking the file type, you can remove it and your code will allow other file extensions too.

    Refer to the following link for more details:
    http://www.php.net/manual/en/features.file-upload.php
    References :

Leave a Reply