The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 2 of 2

Thread: Uploading Images for Form Submission

  1. #1

    Uploading Images for Form Submission

    Hi everyone. I have a bit of an issue. I'm the admin / creator of and I'm trying to enable users to upload images. I've looked all over the web and found a few useful scripts for uploading, but I'm having a problem maintaining the functionality of the rest of my form. Here is the code I'm starting with.

    Form: (found at
    <form method="post" action="sendmail.php" name="msgform">
               <input type="text" name="name" id="name" />
               <input type="text" name="email" id="email" />
             <label>Where ya from?:
               <input type="text" name="location" id="location" />
               How did you hear about
                 <input type="text" name="hear" id="hear" /></label>
             <label>Blackout URL*:
               <input name="image" type="text" id="image" value="http://" />
           <br /><font size="-2">*We are currently working on support of direct upload images.  In the meantime we recommend using a third-party image hosting site, like <a href="" rel="nofollow" target="_blank"></a> or <a href="" rel="nofollow" target="_blank"></a></font>
             <label>Blackout Description (240 Character Limit):
               <br />
               <textarea name="description" cols="60" rows="4" id="description"></textarea>
           <p>Prove you're not a robot: <font size="-4"><a href="javascript:MDM_openWindow('why.html','Interface1','width=270,height=330')">(Why do I have to do this??)</a></font></p>
           <div align="center">
             <script type="text/javascript" src=""></script>
              <iframe src="" height="300" width="500" frameborder="0"></iframe><br/>
              <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
              <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
             <br />
             <input type="submit" value="Submit" />&nbsp;&nbsp;<input type="reset" value="Clear Form" /></p>
    Server Side PHP Script: (sendmail.php)
    $privatekey = "6Lf2gwgAAAAAAEOhPT7XGI4fegpxVUcXEnK8Tm9m";
    $resp = recaptcha_check_answer ($privatekey,
    if(!$resp->is_valid) {
    else if($resp->is_valid) 
    $to = "";
    $subject = "Blackout Poetry Submission";
    $name_field = $_POST['name'];
    $email_field = $_POST['email'];
    $location_field = $_POST['location'];
    $image_field = $_POST['image'];
    $hear_field = $_POST['hear'];
    $description_field = $_POST['description'];
    $body = "From: $name_field\n E-Mail: $email_field\n Location: $location_field\n Heard: $hear_field\n Image: $image_field\n Description: $description_field";
    mail($to, $subject, $body);
     header( "Location:" );

  2. #2
    There is a bit difference from handling normal form fields and file uploads
    First, have enctype="multipart/form-data" in the HTML form
    Then on uploading, the file location will be available in $_FILES["uploaded_file"]["tmp_name"]
    You have to copy the file to a desired location.
    For more information, see this page: PHP email form with file attachment

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012