Creating a PHP mailto form with image uploader?

Discussion in 'PHP' started by chriswick, Mar 28, 2008.

  1. #1
    I want to make a PHP from that people sumbit information to me via an online form I also want them to be able to upload images and submit them to my email box.

    Can anyone give me a useful URL or post some code to help me do this.

    Thanks!
     
    chriswick, Mar 28, 2008 IP
  2. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #2
    PHPMailer is a good place to start as it has a built in function allow mail attachments.

    Building a simple form with upload script should be too difficult. There are plenty of tutorials online to help you do this.
     
    Weirfire, Mar 28, 2008 IP
  3. roshanbh

    roshanbh Peon

    Messages:
    52
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    well why don't you just upload the image and send the url of the image in the email..
     
    roshanbh, Mar 28, 2008 IP
  4. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #4
    That's a very good point! :)
     
    Weirfire, Mar 28, 2008 IP
  5. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Because it's an online web form and users will be sending me information alone with an image file.
     
    chriswick, Mar 28, 2008 IP
  6. singh.ajit05

    singh.ajit05 Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I can help you for this. You can easily add it in your file. I give you a simple example to integrate it..

    //sample.html
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Send ATTachement mail >> By Ajit kumar singh</title>
    </head>
    <body>
    <form action="sendmail.php" method="post" name="f1" id="f1" enctype="multipart/form-data">
    <table id="int" width="100%">
    <tbody>
    <tr>
    <td width="25%" align="left">&nbsp;</td>
    <td width="25%" align="left">&nbsp;</td>
    </tr>

    <tr>
    <td align="left">Name<font color="red">*</font>:<font color="red">&nbsp;</font></td>
    <td align="left"><input name="name" type="text" value="" size="36" id="name" /></td>
    </tr>
    <tr>
    <td align="left">Email<font color="red">*</font>:<font color="red">&nbsp;</font></td>
    <td align="left"><input name="email" type="text" value="" size="36" id="email" /></td>
    </tr>
    <tr>
    <td align="left">summary<font color="red">*</font>:<font color="red"></font></td>
    <td align="left"><textarea name="summary" cols="36"></textarea></td>
    </tr>
    <tr> </tr>
    <tr>
    <td align="left">Upload image<font color="red">*</font>:<font color="red"></font></td>
    <td align="left"><input name="fileatt" type="file"></td>
    </tr>
    </tbody>
    </table>
    <form>
    </body>
    </html>

    //sendmail.php
    <?php
    $extlimit == "yes";
    $limitedext = array(".jpg",".jpeg",".gif");
    $uploadfile="";
    $fileatt=$_FILES['fileatt']['tmp_name'];
    $fileatt_type = $_FILES['fileatt']['type'];
    $fileatt_name = $_FILES['fileatt']['name'];
    // code for check
    $ext = strrchr($_FILES['fileatt']['name'],'.');
    if (($extlimit == "yes") && (!in_array($ext,$limitedext))) {
    echo("Wrong file extension. ");
    exit();
    }

    if($fileatt_name!="")
    {
    $uploadfile=$cpath."resume/".$fileatt_name;
    if (($fileatt_type=="image/pjpeg") || ($fileatt_type=="image/jpeg") || ($fileatt_type=="image/gif"))
    {
    @move_uploaded_file($fileatt , $uploadfile) or die('Resume upload problem.');
    }
    }
    $to="singh.ajit05@hotmail.com";
    $from = $_POST['EMAIL_ADDRESS'];
    $subject = "Just send testing mail";
    $message = "
    Name :- ".$_POST[name]."\n
    E-mail Id :- ".$_POST
     
    singh.ajit05, Mar 29, 2008 IP