Php uploader

Hello.  I am trying to include the ability to upload a file in my website.  I am using the sample code from w3c to try it out.
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000))
  if ($_FILES["file"]["error"] > 0)
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  else
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    if (file_exists("upload/" . $_FILES["file"]["name"]))
      echo $_FILES["file"]["name"] . " already exists. ";
    else
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
else
  echo "Invalid file";
?>
When I use this, every file I try to upload is an "Invalid file".
When I remove restrictions every file I try to upload returns.
Upload:
Type:
Size: 0 Kb
Temp file:
already exists.
The file is uploading.  I have watched "Activity Monitor" and larger files take a correspondingly longer time to upload.
Here is the html.
<div id="picture"><p>Please ensure that your filenames reflect your organization and project, and then click the "Browse" button.</p><form action="uploader.php" method="post" enctype="multipart/form-data" id="upload">
<input type="hidden" name="MAX_FILE_SIZE" value="50000000" />
Choose a file to upload: <input name="uploadedfile" type="file" />
<input type="submit" value="Upload File" />
</form></div>
Here is the .php with restrictions removed except for size.
<?php
if ($_FILES["file"]["size"] < 50000000)
  if ($_FILES["file"]["error"] > 0)
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
  else
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
    if (file_exists("upload/" . $_FILES["file"]["name"]))
      echo $_FILES["file"]["name"] . " already exists. ";
    else
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
else
  echo "Invalid file";
?>
Any help is greatly appreciated.

Every occurrence of this kind of code -
$_FILES["file"]["type"]
should be replaced with this -
$_FILES["uploadedfile"]["type"]

Similar Messages

  • [SOLVED]php, upload file more then 980mb

    Hi!
    I have a problem: I want to upload file about 2G. file uploads in /tmp while its size not more then ~980mb, after that he deleted and ~1.2G go to /dev/null
    httpd was restart after I changed in php.ini
    post_max_size = 30G
    upload_max_filesize = 30G
    error  UPLOAD_ERR_CANT_WRITE:    "Failed to write file to disk";
    files less 900mb upload normally
    Last edited by x1site (2014-07-22 09:53:56)

    slithery wrote:
    Do you only have 2G of RAM by any chance?
    The /tmp filesystem is mounted in RAM and limited to half the amount of total memory. If this is your issue then either change the download location to somewhere else or adjust your tmpfs settings.
    I have changed
    upload_tmp_dir = /srv/temp
    open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/srv/temp
    it helped me. thx
    Last edited by x1site (2014-07-22 09:53:44)

  • Dreamweaver PHP Uploader Form

    Hey all,
    Ok here's something that I haven't done much of, I'm looking for a tutorial on creating a page that would allow the user to upload files such as pictures for instance, then I need a page to store those pictures, I know it can be done in DW with a bit of PHP knowledge, I'm ok there.....  Could some one be so kind as to direct me to such a tutorial?
    Thanks in advance
    Allen

    Thanks David!....does the link you provided contain instructions to upload files to another HTML page as opposed to a server?
    Thanks so much
    Allen

  • PHP Upload script for ZIP/SIT files

    Hi,
    I'm trying to locate a decent script that would allow clients
    to upload files to a Web site that I am working on. I found a basic
    one that works at www.w3schools.com/PHP/php_file_upload.asp.
    However, it lack the capabilities to upload zip and sit files.
    Could I modify the existing script that I just mentioned?
    Unfortunately, I am not very PHP saavy. I have been Googling for
    such a script but have not found one yet. I hope some one could
    recommend a decent script. Thanks.

    .oO(Mark A. Boyd)
    >Carlton Chin posted in macromedia.dreamweaver.appdev:
    >
    >> I'm trying to locate a decent script that would
    allow clients to
    >> upload files to a Web site that I am working on. I
    found a basic
    >> one that works at
    www.w3schools.com/PHP/php_file_upload.asp.
    >> However, it lack the capabilities to upload zip and
    sit files.
    >> Could I modify the existing script that I just
    mentioned?
    >
    >The ticket is where the script is checking
    $_FILES["file"]["type"].
    >See
    http://www.w3schools.com/media/media_mimeref.asp
    >
    >If you only want to allow zip/sit, try changing this:
    >
    ><?php
    >if ((($_FILES["file"]["type"] == "image/gif")
    >|| ($_FILES["file"]["type"] == "image/jpeg")
    >|| ($_FILES["file"]["type"] == "image/pjpeg"))
    >&& ($_FILES["file"]["size"] < 20000))
    Be careful. These informations can be faked or might not be
    available at
    all. I can easily upload a PHP script as "image/jpeg". If the
    file ends
    up in a public directory within the document root, I can
    execute it and
    then have a look at the entire server ...
    Relying on the content type or file extension is a huge
    security hole!
    I'm quite surprised that W3Schools publishes such an insecure
    script.
    To make sure that an uploaded file is really of the type you
    expect, you
    must look at its content! For images you can use
    getimagesize(), which
    will also return the type if it's a valid image. For other
    types you
    have to use other libs or external tools. On a *nix machine
    you could
    execute the shell command 'file' for example, which
    recognizes quite a
    lot of different file types.
    Micha

  • Asp and php upload code

    does any one have the code for upload-file form in asp,
    asp.net and php?
    files-path must go to an access database and the file to a
    folder, or is this not possible?
    many thanks

    Yes. OS X is a great webserver.
    OS X includes the Apache web server, so for basic pages there is no need to install anything. However, I recommend that you use Marc Liyanage's PHP package from http://www.entropy.ch/software/macosx/php/. It's really easy to install, and you can also use it with MySQL quite easily.
    If you want something else, XAMPP is also available for OS X at http://www.apachefriends.org/en/xampp.html. There even is a package called MAMP at http://www.mamp.info/. I haven't used these packages much, because the stuff mentioned in the previous paragraph suit my local testing needs.
    Unfortunately, I've never heard of people running ASP on mac. I doubt it's possible, but maybe someone else can help you out with that.

  • Macromedia Dreamweaver Forum Design PHP Uploading on to Web.

    I have downloaded the php files from
    here
    and I have tryed to test it out by uploading it but it does not
    work and it comes out looking different to the Design view in
    Dreamweaver 8.
    I have uploaded everything in the Complete_app folder as I
    want just the complete one but it does not work.
    Please Assist me.
    Regards
    Gareth Cork

    I have used ht-dogs to upload it.

  • Password authentification for as3 php upload

    Hi
    I'm making an Air file that uploads and overwrites an XML file.
    So far, the php is very simple:
    $everything = $_POST['saveThisXML'];
      $everything = stripslashes($everything);
       $toSave = $everything; 
       $fp = fopen("settings.xml", "w");
       if(fwrite($fp, $toSave)) echo "writing=Ok";
       else echo "writing=Error";
       fclose($fp);
    I'd like to set up a user name and passowrd that the user enters in the Air app.  Is it then just a matter of sending POST data to the php file, and have it check the user and pass variables?  Is that a reasonably safe way to do it?  If not, can someone please point me in th edirection of a good tutorial that they're used on this topic?
    Thanks again guys.
    Shaun

    OK
    So somewhere along the line, the user is going to have to set up a database.  I can use PHP to do that though, right?  And they'd just have to run the php page once to set it up.
    Thanks kglad.
    Also, I can successfully upload data from a string (myString) in Flash using PHP:
    var myData:URLRequest = new URLRequest("http://www.blah.com/saver.php");
            myData.method = URLRequestMethod.POST;
            var variables:URLVariables = new URLVariables();
            var origEverything:String = myString;
            variables.saveThisXML = origEverything;       
            myData.data = variables;
            var loadData:URLLoader = new URLLoader();
            loadData.dataFormat = URLLoaderDataFormat.VARIABLES;
            loadData.addEventListener(Event.COMPLETE, doneBaby);
            loadData.addEventListener(IOErrorEvent.IO_ERROR, dataLoadError);
            loadData.load(myData);  
    However, when I try to add two variables to send to php, I get a named pairs error.  Here's what I tried adding (in bold):
    var myData:URLRequest = new URLRequest("http://www.blah.com/saver.php");
             myData.method = URLRequestMethod.POST;
             var variables:URLVariables = new URLVariables();
             var origEverything:String = myString;
              var passTest:String = 'testPW';
             variables.saveThisXML = origEverything;     
         variables.saveThisPass = passTest;     
            myData.data = variables;
             var loadData:URLLoader = new URLLoader();
             loadData.dataFormat = URLLoaderDataFormat.VARIABLES;
             loadData.addEventListener(Event.COMPLETE, doneBaby);
             loadData.addEventListener(IOErrorEvent.IO_ERROR, dataLoadError);
             loadData.load(myData);  
    Why would that generate an error?
    Cheers kglad
    Shaun

  • PHP upload

    Hello,
    I am using Dreamweaver Mx 2004 to develop a PHP site. I am
    trying to
    implement a file upload page but I have run into a problem.
    Users are
    supposed to select a file from one page and this file is
    supposed to be
    uploaded using another. This is a snippet from the page where
    the user
    selects the file:
    <form action="upload.php" method="post"
    enctype="multipart/form-data"
    name="form1">
    <label for="file">Filename:</label>
    <table width="200" border="1">
    <tr>
    <td width="133"><input name="filefld" type="file"
    id="filefld"></td>
    <td width="51"> </td>
    </tr>
    <tr>
    <td><input type="submit" name="Submit"
    value="Submit"></td>
    <td> </td>
    </tr>
    </table>
    </form>
    The contents of the upload.php file are as follows:
    <?php
    if $_FILES["file"]["type"] == "image/pjpeg")
    if ($_FILES["file"]["error"] > 0)
    echo "Return Code: " . $_FILES["file"]["error"] . "<br
    />";
    else
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . "
    Kb<br />";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br
    />";
    if (file_exists("photos/" . $_FILES["file"]["name"]))
    echo $_FILES["file"]["name"] . " already exists. ";
    else
    move_uploaded_file($_FILES["file"]["tmp_name"],
    "photos/" . $_FILES["file"]["name"]);
    echo "Stored in: " . "photos/" . $_FILES["file"]["name"];
    else
    echo "Invalid file";
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN"
    http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    </head>
    <body>
    </body>
    </html>
    After selecting a .JPG file I click on the submit button and
    the upload.php
    file loads but nothing happens (meaning that the selected
    file is not
    downloaded). I have checked the php.ini file to ensure that
    all the
    necessary setting are there and that the temp upload folder
    has the
    necessary windows permissions but still no luck. Any help
    would be
    appreciated.
    Liam

    both suggestions worked out fine. Thanks for the help.
    Liam
    "David Powers" <[email protected]> wrote in message
    news:f9eqlg$dh4$[email protected]..
    > MikeL7 wrote:
    >> I think you need to change to this:
    >>
    >> @copy($_FILES["filefld"]["tmp_name"],
    >> "photos/" . $_FILES["filefld"]["name"]);
    >
    > Using copy for an uploaded file is a major security
    risk. You should use
    > move_uploaded_file() instead.
    >
    >
    http://www.php.net/manual/en/function.move-uploaded-file.php
    >
    > --
    > David Powers, Adobe Community Expert
    > Author, "The Essential Guide to Dreamweaver CS3"
    (friends of ED)
    > Author, "PHP Solutions" (friends of ED)
    >
    http://foundationphp.com/

  • What is the default directory for the PHP uploads, i.e. upload_tmp_dir = ?

    I would like to know the default directory that is referenced in the php.ini file under the category of "upload_tmp_dir =" for the OS X server 10.5.8.

    This is the best info that I have found:
    http://bugs.php.net/52460
    Still, just wondering what the default for 10.5.8 is supposed to be before I go and change the php.ini entries.

  • PHP upload only jpg, gif

    I 've been working with this file for a day now and I can
    upload files but I want the user to be able to upload certain types
    of files. Like jpg, gif or pdf. The number of items uploadable are
    determined by a previous page submitted. Here is my code any help
    would be greatly appreciated.
    <?
    // start of dynamic form
    $uploadNeed = $_POST['uploadNeed'];
    for($x=0;$x<$uploadNeed;$x++){
    ?>
    <input name="uploadFile<? echo $x;?>" type="file"
    id="uploadFile<? echo $x;?>">
    </p>
    <?
    // end of for loop
    ?>
    <p>
    <input name="uploadNeed" type="hidden" value="<? echo
    $uploadNeed;?>">
    <input name="filename" type="hidden" id="filename" value="
    <?
    $UploadExts = array('gif','jpeg','jpg');
    $uploadNeed = $_POST['uploadNeed'];
    // start for loop
    for($x=0;$x<$uploadNeed;$x++){
    // strip file_name of slashes
    $file_name = stripslashes($file_name);
    $file_name = str_replace("'","",$file_name);
    $file_name = $_FILES['uploadFile'. $x]['name']['type'];
    $file_ext =
    strtolower(substr($file_name,strrpos($file_name,".")));
    //File Extension Check
    if (!in_array($file_ext, $UploadExts))
    $file_ext = substr(strtolower(strrchr($file_name,'.')),1);
    $copy = copy($_FILES['uploadFile'.
    $x]['tmp_name'],$file_name);
    else
    $message = "Sorry, $file_name($file_type) is not allowed to
    be uploaded.";
    // check if successfully copied
    if($copy){
    echo "$file_name | uploaded Successfully!><br>";
    }else{
    echo "$file_name | Could Not Be Uploaded!<br>";
    // end of loop
    ?>">

    im afraid not...
    I've been googlin for a solution for this problem for some time, and i got nothing!
    All that i got was that there is a property for the "file" html input component that's called "accept" which you can add a list of MIME types that you want to be listed in the upload file dialog... But the funny thing is... Its only in the W3C standard an none of the current browsers support it till now!!!! = |
    The only solution that they gave till now, is to use javascript to check the file name value when submitting the form and make sure that the extension is like what you want, else report it in an alertbox for the user that he change the file type cause its not supported! How absurd! =/
    If anyone could find a solution for this thing, i'll be happy to know...

  • Adobe toolbox vs PHP pure upload?

    Been using MX 2004 and enjoyed the PHP pure file upload
    behavior.
    Now downloaded the trial version of DW CS3 and find that my
    file upload behavior wont work, then downloaded the toolbox and
    find that it's so much more different than my usual way of
    uploading files.
    What about the sites that I have developed before with the
    PHP file upload behavior?
    Would I now need to redo every site?
    Cheers

    >>
    What about the sites that I have developed before with the
    PHP file upload behavior?
    Would I now need to redo every site?
    >>
    As the Developer Toolbox "file upload" behaviour uses some
    proprietary methods
    (that certainly applies to the PHP file upload behavior as
    well), you would indeed have to create new file upload pages.
    Was just looking at the "Pure PHP Upload 2" page (
    http://www.dmxzone.com/ShowDetail.asp?NewsId=4509),
    and the specs claim that it´s compatible with Dreamweaver
    CS3

  • Inserting & uploading records with Dreamweaver CS3, MYSQL & PHP

    I'm able to build a web page that allows for images to be
    uploaded to a server folder. Also have a web page created to insert
    info about the image into a MYSQL/PHP database.
    My goal is to find a way to combine the two together so that
    when you click the submit button... 1) the image gets uploaded to
    the server folder, 2) the info about the image gets placed into the
    database table, and 3) there is an entry in the database that
    establishes the path to the image.
    Any help or direction to a tutorial would be greatly
    appreciated.

    I use a DW extension from DMXzone (Pure PHP Upload) that
    allows me to both insert data form an online form into a MySQL
    table as well as upload files to a directory on the server with one
    button click. This might be a solution for you.

  • For uploading PDF (in php) if (!=application/pdf) {"No PDF"} gives error when trying to upload PDF. Why?

    In a php upload file I have inserted:
    if($_FILES['file']['type'] !="application/pdf"){ echo "Should be PDF";}
    exit;
    Even when trying to upload a PDF file the error message comes: Should be PDF.
    Earlier this worked fine. Maybe a bug in an update?
    Regards,
    pluys

    I think I found part of a solution now. It is not Firefox, it is some add-on or plug-in. I myself use a lot of add-ons. I asked someone who was new to Firefox to load up a PDF file. There was no problem!
    So now I'm going to check all my add-ons, hoping it is not Firebug.
    All the best,
    Pluys

  • Uploading files to website not working with Safari in Windows 7

    Safari version: 5.1.7
    OS: Windows 7
    Hi,
    I am a website owner, and I have a feature on my site where users can upload large (up to 50MB) music files to my server. The feature works in Firefox on OSX & Windows platforms and it also works in Safari on OSX. The uploading feature is not working with Safari for Windows. Do you have any idea why and how to fix this? It can't be an issue with my server as it works in other browsers fine and works fine in Safari for OS X.
    If you have any information on how to solve this or things for me to try to rectify this for use with Windows operating system it would be much appreciated.
    Thanks.

    GREAT NEWS!!!!
    I have solved this issue myself with some help from my a user on Microsoft Forums. The issue stems from the mime type of each Browser Chrome, IE, & Safari for Windows defaults as audio/wav. When the mime type is changed to audio/x-wav everything works. Firefox defaults to audio/x-wav and when changed to audio/wav it DOES NOT work.
    Once I input some code in my .php upload page to change the mimetype if audio/wav is detected everything works GREAT!!!
    So Here is what you need to do: Find your upload page and input this code:
    echo "<p>MIME Type: ".$_FILES["file"]["type"]."</p>";   
    right before your "If/then" statement of file type. For me it was near line 30 in my upload.php page, but I'm sure this is different for everyone.
    This will detect and DISPLAY the default mime type of your browser on the error page when your upload doesn't work. Once you know what mime type works for your file type then you can change your "if/then" statement for mime type upload to change your mime type to the correct one.
    I don't want to give the code here, because I'm sure it's specific to your file types and your site construction, but this should lead you on the right track.
    ***This is the solution if you ARE NOT ABLE to upload any certain file in a certain Browser. It has to do with mime type construction***
    I hope this helps others like it helped me!!!!!

  • Storing Uploaded Image Path into Mysql

    Hi I am developing a cms and am using the code David gives in his book PHP Solutions,  everything works fine but I can't work out how to extract the uploaded path so that it is stored in my table.
    Help would be really appreciated, I am making good progress in learning the php especially with David's books but am still struggling when it comes to having to customized the code.
    The code for the upload.php is as follows,
    <?php
    class Gp1_Upload{
      protected $_uploaded = array();
      protected $_destination;
      protected $_max = 51200;
      protected $_messages = array();
      protected $_permitted = array('image/gif',
                                    'image/jpeg',
                                    'image/pjpeg',
                                    'image/png');
      protected $_renamed = false;
      public function __construct($path) {
        if (!is_dir($path) || !is_writable($path)) {
          throw new Exception("$path must be a valid, writable directory.");
        $this->_destination = $path;
        $this->_uploaded = $_FILES;
      public function getuploadpath (){
      public function getMaxSize() {
        return number_format($this->_max/1024, 1) . 'kB';
      public function setMaxSize($num) {
        if (!is_numeric($num)) {
          throw new Exception("Maximum size must be a number.");
        $this->_max = (int) $num;
      public function move($overwrite = false) {
        $field = current($this->_uploaded);
        if (is_array($field['name'])) {
          foreach ($field['name'] as $number => $filename) {
            // process multiple upload
            $this->_renamed = false;
            $this->processFile($filename, $field['error'][$number], $field['size'][$number], $field['type'][$number], $field['tmp_name'][$number], $overwrite);   
        } else {
          $this->processFile($field['name'], $field['error'], $field['size'], $field['type'], $field['tmp_name'], $overwrite);
      public function getMessages() {
        return $this->_messages;
      protected function checkError($filename, $error) {
        switch ($error) {
          case 0:
            return true;
          case 1:
          case 2:
            $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
            return true;
          case 3:
            $this->_messages[] = "Error uploading $filename. Please try again.";
            return false;
          case 4:
            $this->_messages[] = 'No file selected.';
            return false;
          default:
            $this->_messages[] = "System error uploading $filename. Contact webmaster.";
            return false;
      protected function checkSize($filename, $size) {
        if ($size == 0) {
          return false;
        } elseif ($size > $this->_max) {
          $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
          return false;
        } else {
          return true;
      protected function checkType($filename, $type) {
        if (empty($type)) {
          return false;
        } elseif (!in_array($type, $this->_permitted)) {
          $this->_messages[] = "$filename is not a permitted type of file.";
          return false;
        } else {
          return true;
      public function addPermittedTypes($types) {
        $types = (array) $types;
        $this->isValidMime($types);
        $this->_permitted = array_merge($this->_permitted, $types);
      protected function isValidMime($types) {
        $alsoValid = array('image/tiff',
                           'application/pdf',
                           'text/plain',
                           'text/rtf');
          $valid = array_merge($this->_permitted, $alsoValid);
        foreach ($types as $type) {
          if (!in_array($type, $valid)) {
            throw new Exception("$type is not a permitted MIME type");
      protected function checkName($name, $overwrite) {
        $nospaces = str_replace(' ', '_', $name);
        if ($nospaces != $name) {
          $this->_renamed = true;
        if (!$overwrite) {
          $existing = scandir($this->_destination);
          if (in_array($nospaces, $existing)) {
            $dot = strrpos($nospaces, '.');
            if ($dot) {
              $base = substr($nospaces, 0, $dot);
              $extension = substr($nospaces, $dot);
            } else {
              $base = $nospaces;
              $extension = '';
            $i = 1;
            do {
              $nospaces = $base . '_' . $i++ . $extension;
            } while (in_array($nospaces, $existing));
            $this->_renamed = true;
        return $nospaces;
      protected function processFile($filename, $error, $size, $type, $tmp_name, $overwrite) {
        $OK = $this->checkError($filename, $error);
        if ($OK) {
          $sizeOK = $this->checkSize($filename, $size);
          $typeOK = $this->checkType($filename, $type);
          if ($sizeOK && $typeOK) {
            $name = $this->checkName($filename, $overwrite);
            $success = move_uploaded_file($tmp_name, $this->_destination . $name);
            if ($success) {
                $message = "$filename uploaded successfully";
                if ($this->_renamed) {
                  $message .= " and renamed $name";
                $this->_messages[] = $message;
            } else {
              $this->_messages[] = "Could not upload $filename";
    ?>
    The code for my form page is this
    <!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>Untitled Document</title>
    </head>
    <body>
    <?php
    //THE FOLLOWING CODE IS FOR THE UPLOADING OF IMAGES AND FILES
    // set the max upload size in bytes
    $max = 51200;
    if (isset ($_POST ['submit']))
                //define the path to the upload folder
                $destination = 'uploads/';
                require_once('classes/Upload.php');
                try {
                    $upload = new Gp1_Upload($destination);
                    $upload->setMaxSize($max);
                    $upload->move();
                    $result = $upload->getMessages();
                } catch (Exception $e) {
                    echo $e->getMessage();
    // END OF UPLOADING OF IMAGES AND FILES
    ?>
    <form id="newvenue" action="" method="post" enctype="multipart/form-data" >
          <?php
               // THIS CODE DISPLAYS ERROR MESSAGES FOR THE FILE UPLOADS
              if (isset($result)){
              echo '<ul>';
              foreach ($result as $message){
                  echo "<li>$message</li>";
              echo '</ul>';
           ?>
      <table id="neweventdisplay" cellpadding="5"  border="0">
        <tr>
      <td></td>
      <td><input type="hidden" name="user_id"  value="" /></td>
      </tr>
      <tr>
      <td></td>
        <td>Organisers Name</td>
        <td><input class="input80px" id="org_name" name="org_name" type="text" /> </td>
      </tr>
      <tr>
      <td></td>
      <td><label for="image">Upload image:</label></td>
      <td><p>
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>" />
    <input type="file" name="image" id="image" />
    </p></td>
    </tr>
      <tr>
      <td></td>
      <td>Details about your upload</td>
      <td><input class="input80px" id="org_uploadcapt" name="org_uploadcapt" type="text"  /></td>
    </tr>
      <tr>
      <td></td>
      <td><input type="submit" name="submit" id="submit" value="upload"></td>
      </tr>
      <tr>
      <td class="heading"> </td>
      <td></td>
      </tr>
    </table>
    </form>
    <prep>
    <?php
    if (isset ($_POST ['submit'])){
        print_r($_FILES);}
        ?>
        </prep>
    </body>
    </html>

    Hi David
    Thank you very much for your help.  I had continued to work on the code and had worked out how to input the image path into the database but it was using the original filename, so when every it is changed it did not work.  The code in my page at that point was the following,
    <?php     // 2. NEW USER REGISTRATION<br />
            include_once ("includes/form_functions.inc.php");
            $max = 100000;
            $destination = 'uploads/';
            // START FORM PROCESSING FOR A NEW REGISTRATION
            if (isset($_POST['submit'])) { // Form has been submitted.
            $errors = array();
            // perform validations on the form data
            $required_fields = array('org_name');
            $errors = array_merge($errors, check_required_fields($required_fields, $_POST));    
            $required_numberfields = array('user_id');
            $errors = array_merge($errors, check_number_fields($required_numberfields, $_POST));
            $fields_with_lengths = array('org_name' => 36, 'org_website' => 100, 'org_contact' => 40,  'org_conemail' => 80, 'org_contel' => 30);
            $errors = array_merge($errors, check_max_field_lengths($fields_with_lengths, $_POST));
            /*Here I am using trim as well as ucwords, this function converts the first letter of each work into a capital letter,  I am using this only on the
            firstname and surname to ensure that the data is how I want it as it is going  into the database,  The better the data is preformated the better the data
            swill be within the database.*/
            $org_name = trim(strtolower(mysql_prep($_POST['org_name'])));
            $org_website = trim(strtolower(mysql_prep($_POST['org_website'])));
            $org_contact = trim(strtolower (mysql_prep($_POST['org_contact'])));
            $org_conemail = trim(strtolower (mysql_prep($_POST['org_conemail'])));
            $org_contel = strtolower (mysql_prep($_POST['org_contel']));
            $userid = $_POST['user_id'];
            $org_uploadcapt = $_POST['org_uploadcapt'];
            $image = $_FILES['image'];
            /*Here is the code that takes the variable captured from the input form and matches it  up with the appropriate field in the database.  An important point with insertion is that  the variables are in the same order as the mysql field names, there will be an error if the number of variables does not match the number of field names.  Note that there is no entry for the user id as this is an auto increment file within mysql and so is not needed to be entered*/
            if ( empty($errors) ) {
                $sql = "INSERT INTO organiser
                          (org_name, org_website, org_contact, org_conemail, org_contel, user_id, org_uploadurl, org_uploadcapt)
                          VALUES
                          ('{$org_name}', '{$org_website}', '{$org_contact}', '{$org_conemail}', '{$org_contel}', '{$userid}', '{$destination}".$image['name']."', '{$org_uploadcapt}' )";
                $result = mysql_query($sql, $connection);
                if ($result) {
                    $message = "The organiser was successfully created.<br />";
                } else {
                    $message = "I am sorry but the organiser could not be added.";
                    $message .= "<br />" . mysql_error();
                } else {
                    /* this counts the number of errors and informs the user of how many fields were
                    incorrectly entered*/
                if (count($errors) == 1) {
                    $message = "There was 1 error in the form.";
                } else {
                    $message = "There were " . count($errors) . " errors in the form.";
        } else { // Form has not been submitted.
            $org_name = "";
            $org_website = "";
            $org_contact = "";
            $org_conemail = "";
            $org_contel = "";
            $userid = "";
            $org_uploadcapt = "";
    //THE FOLLOWING CODE IS FOR THE UPLOADING OF IMAGES AND FILES
    // set the max upload size in bytes
    if (isset ($_POST ['submit']))
                //define the path to the upload folder
                // Use This On The Local Hosting Machine
                //$destination = 'C:/upload_test/';
                // Use This On The Live Server
                require_once('classes/Upload.php');
                try {
                    $upload = new Gp1_Upload($destination);
                    $upload->setMaxSize($max);
                    $upload->move();
                    $result = $upload->getMessages();
                } catch (Exception $e) {
                    echo $e->getMessage();
    // END OF UPLOADING OF IMAGES AND FILES
    ?>
    <title>Horse Events</title>
    <?php include_once("includes/meta.inc.php");?>
    <?php include_once("includes/cssfavgoogle.inc.php");?>
    <link href="css/adminpanel.css" rel="stylesheet" type="text/css" />
    <style>
    input[type="number"] {
        width:40px;
    </style>
    </head>
    <body>
    <div id="wrapper">
        <div id="admincontent">
    <form id="newvenue" action="neworganiser.php" method="post" enctype="multipart/form-data" >
          <?php if (!empty ($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
          <?php if (!empty ($errors)) {display_errors($errors); } ?>
          <?php
              // THIS CODE DISPLAYS ERROR MESSAGES FOR THE FILE UPLOADS
              if (isset($result)){
              echo '<ul>';
              foreach ($result as $message){
                  echo "<li>$message</li>";
              echo '</ul>';
           ?>
    <br />
          <table id="neweventdisplay" cellpadding="5"  border="0">
        <tr>
      <td></td>
      <td><input type="hidden" name="user_id"  value="<?php echo $url_userid ['user_id']; ?>" /></td>
      </tr>
      <tr>
      <td> <span class="compuls">*</span></td>
        <td>Organisers Name</td>
        <td><input class="input80px" id="org_name" name="org_name" type="text" />
         </td>
      </tr>
          <tr>
          <td><span class="compuls">*</span></td>
        <td>Their Website</td>
        <td><input class="input80px" id="org_website" name="org_website" type="text" /></td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
        <td>Organisers Contact</td>
        <td><input id="org_contact" name="org_contact" type="text" />eg: Mrs Jean Kelly</td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
        <td>Contact Email</td>
        <td><input class="input80px" id="org_conemail" name="org_conemail" type="text" />
          </td>
      </tr>
        <tr>
        <td><span class="compuls">*</span></td>
      <td>Contact Tel No.</td>
      <td><input id="org_contel" name="org_contel" type="text" /></td>
      </tr>
      <tr>
      <td></td>
      <td><label for="image">Upload image:</label></td>
      <td><p>
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max; ?>" />
    <input type="file" name="image" id="image" />
    </p></td>
    </tr>
      <tr>
      <td></td>
      <td>Details about your upload</td>
      <td><input class="input80px" id="org_uploadcapt" name="org_uploadcapt" type="text"  /></td>
    </tr>
      <tr>
      <td></td>
      <td><input type="submit" name="submit" id="submit" value="Add Your Organiser"></td>
      </tr>
      <tr>
      <td class="heading"> </td>
      <td></td>
      </tr>
    </table>
    <a  class="delete" href="controlpanel.php">Cancel</a>
    </form>
        </div>
    I have added the code you kindly forwarded but am getting an error,  I am still trying to learn the basics of php and am unsure of what to do next, my php Upload.php now looks like
    <?php
    class Gp1_Upload{
      protected $_uploaded = array();
      protected $_destination;
      protected $_max = 100000;
      protected $_messages = array();
      protected $_permitted = array('image/gif',
                                    'image/jpeg',
                                    'image/pjpeg',
                                    'image/png');
      protected $_renamed = false;
      protected $_filenames = array();
      public function __construct($path) {
        if (!is_dir($path) || !is_writable($path)) {
          throw new Exception("$path must be a valid, writable directory.");
        $this->_destination = $path;
        $this->_uploaded = $_FILES;
      public function getMaxSize() {
        return number_format($this->_max/100000, 1) . 'kB';
      public function setMaxSize($num) {
        if (!is_numeric($num)) {
          throw new Exception("Maximum size must be a number.");
        $this->_max = (int) $num;
      public function move($overwrite = false) {
        $field = current($this->_uploaded);
        if (is_array($field['name'])) {
          foreach ($field['name'] as $number => $filename) {
            // process multiple upload
            $this->_renamed = false;
            $this->processFile($filename, $field['error'][$number], $field['size'][$number], $field['type'][$number], $field['tmp_name'][$number], $overwrite);   
        } else {
          $this->processFile($field['name'], $field['error'], $field['size'], $field['type'], $field['tmp_name'], $overwrite);
      public function getMessages() {
        return $this->_messages;
      protected function checkError($filename, $error) {
        switch ($error) {
          case 0:
            return true;
          case 1:
          case 2:
            $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
            return true;
          case 3:
            $this->_messages[] = "Error uploading $filename. Please try again.";
            return false;
          case 4:
            $this->_messages[] = 'No file selected.';
            return false;
          default:
            $this->_messages[] = "System error uploading $filename. Contact webmaster.";
            return false;
      protected function checkSize($filename, $size) {
        if ($size == 0) {
          return false;
        } elseif ($size > $this->_max) {
          $this->_messages[] = "$filename exceeds maximum size: " . $this->getMaxSize();
          return false;
        } else {
          return true;
      protected function checkType($filename, $type) {
        if (empty($type)) {
          return false;
        } elseif (!in_array($type, $this->_permitted)) {
          $this->_messages[] = "$filename is not a permitted type of file.";
          return false;
        } else {
          return true;
      public function addPermittedTypes($types) {
        $types = (array) $types;
        $this->isValidMime($types);
        $this->_permitted = array_merge($this->_permitted, $types);
      protected function isValidMime($types) {
        $alsoValid = array('image/tiff',
                           'application/pdf',
                           'text/plain',
                           'text/rtf');
          $valid = array_merge($this->_permitted, $alsoValid);
        foreach ($types as $type) {
          if (!in_array($type, $valid)) {
            throw new Exception("$type is not a permitted MIME type");
      protected function checkName($name, $overwrite) {
        $nospaces = str_replace(' ', '_', $name);
        if ($nospaces != $name) {
          $this->_renamed = true;
        if (!$overwrite) {
          $existing = scandir($this->_destination);
          if (in_array($nospaces, $existing)) {
            $dot = strrpos($nospaces, '.');
            if ($dot) {
              $base = substr($nospaces, 0, $dot);
              $extension = substr($nospaces, $dot);
            } else {
              $base = $nospaces;
              $extension = '';
            $i = 1;
            do {
              $nospaces = $base . '_' . $i++ . $extension;
            } while (in_array($nospaces, $existing));
            $this->_renamed = true;
        return $nospaces;
      protected function processFile($filename, $error, $size, $type, $tmp_name, $overwrite) {
        $OK = $this->checkError($filename, $error);
        if ($OK) {
          $sizeOK = $this->checkSize($filename, $size);
          $typeOK = $this->checkType($filename, $type);
          if ($sizeOK && $typeOK) {
            $name = $this->checkName($filename, $overwrite);
            $success = move_uploaded_file($tmp_name, $this->_destination . $name);
            if ($success) {
                $message = "$filename uploaded successfully";
                if ($this->_renamed) {
                  $message .= " and renamed $name";
                $this->_messages[] = $message;
            } else {
              $this->_messages[] = "Could not upload $filename";
      public getFilenames() {
        return $this->_filenames;
    ?>
    The error is Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE.   
    I have not worked with oop before and have only very briefly looked at the principle was on my foundation degree.

Maybe you are looking for