Web Analytics Made Easy -
StatCounter combine a form with an upload script - CodingForum

Announcement

Collapse
No announcement yet.

combine a form with an upload script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • combine a form with an upload script

    Hi

    I have a standard html form. The form is rather long (but is at the bottom of this post if needed). Its essentially a contact form, which submits to a page that sends an email, and places the entries in a database. I need to add a field for uploading. I have been having my users upload seperately, but this has led to many problems - i really need to combine them into one form. I have been using the using the following scripts:

    The upload form:
    Code:
    <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form action="upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td><strong>Single File Upload </strong></td>
    </tr>
    <tr>
    <td>Select file
    <input name="ufile" type="file" id="ufile" size="50" /></td>
    </tr>
    <tr>
    <td align="center"><input type="submit" name="Submit" value="Upload" /></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>
    And the php:
    PHP Code:
    <?php
    //set where you want to store files
    //in this example we keep file in folder upload
    //$HTTP_POST_FILES['ufile']['name']; = upload file name
    //for example upload file name cartoon.gif . $path will be upload/cartoon.gif
    $path"upload/".$HTTP_POST_FILES['ufile']['name'];
    if(
    $ufile !=none)
    {
    if(
    copy($HTTP_POST_FILES['ufile']['tmp_name'], $path))
    {
    echo 
    "Successful<BR/>";

    //$HTTP_POST_FILES['ufile']['name'] = file name
    //$HTTP_POST_FILES['ufile']['size'] = file size
    //$HTTP_POST_FILES['ufile']['type'] = type of file
    echo "File Name :".$HTTP_POST_FILES['ufile']['name']."<BR/>";
    echo 
    "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>";
    echo 
    "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>";
    echo 
    "<img src=\"$path\" width=\"150\" height=\"150\">";
    }
    else
    {
    echo 
    "Error";
    }
    }
    ?>
    The contact form:
    is too long to fit on in this post, so uploaded here

    If anyone knows how to get these 2 together, that would be great
Working...
X