Help With Image Upload

Discussion in 'PHP' started by GeelongTECH, Feb 11, 2011.

  1. #1
    Hello,
    I have a form like:
    <form method="post" action="/admin/post.php">
    <div style="width:650px;text-align:right;">
    ID: <input type="text" name="id" value="1" /><br/>
    Name: <input type="text" name="name" /><br/>
    Category: <select name="category">
    <option value="html">HTML</option>
    <option value="wp">WP</option>
    
    </select><br/>
    Small Image:<input type="file" name="small_img_url" id="small_img_url" /><br/>
    Big Image:<input type="file" name="big_img_url" id="big_img_url" /><br/>
    HotFile: <input type="text" name="hotfile" value="" /><br/>
    FileSonic: <input type="text" name="filesonic" value="" /><br/>
    Easy-Share: <input type="text" name="easyshare" value="" /><br/>
    Demo: <input type="text" name="Demo" value="" /><br/>
    Active: <input type="radio" name="active" value="yes" checked>Yes <input type="radio" name="active" value="no">No
    </div>
    <textarea id="post" name="post" rows="15" cols="80" style="width: 100%"></textarea>
    <input type="submit" value="Submit" name="save" />
    </form>
    HTML:
    Where Small Image and Big Image are there is a file upload, I need the code for post.php that will post "Small Image" to /home/sharing/public_html/images/small/ (or http://example.com/images/small/ and post "Big Image" to /home/sharing/public_html/images/big/ (or http://example.com/images/big/

    The Image file will be JPG, PNG or GIF, the image file name needs to be set by $small_image_name and $big_image_name.

    Thanks
    Chris
     
    GeelongTECH, Feb 11, 2011 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    What you have tried so far?
     
    mwasif, Feb 12, 2011 IP
  3. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    first you need to add enctype="multipart/form-data"
    to your form tag as it is necessary to upload the file via your post
     
    srisen2, Feb 14, 2011 IP
  4. le_punk

    le_punk Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it must be the enctype problem. I forget to add it all the time
    google "php file upload" and you will get some good tutorials
     
    le_punk, Feb 15, 2011 IP