1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need help with a form and PHP file upload

Discussion in 'PHP & Perl' started by bizbez, Nov 27, 2011.

  1. bizbez

    bizbez Registered Member

    Joined:
    Jan 26, 2011
    Messages:
    86
    Likes Received:
    3
    hi all,

    i have a simple POST form on my site which i need the users to upload files also. the form sends all the fields content to the DB.

    my question is:

    how should i write this in PHP - so users can upload a file and when they click submit - the location of the file, along with the other form fields are sent to the database, and the uploaded file is being uploaded.

    please help,

    thanks
     
  2. xpwizard

    xpwizard Junior Member

    Joined:
    Nov 6, 2010
    Messages:
    198
    Likes Received:
    122
    W3 schools explains this pretty well:

    Code:
    http://www.w3schools.com/php/php_file_upload.asp
    Pretty much what you will need to do is two files (same concept for ajax). One will contain the form and will probably just be on your normal site. The next will be a validation form that will process the fields/add them to the DB and save the file.