best method to implement file upload?

Discussion in 'Programming' started by olddocks, Nov 16, 2007.

  1. #1
    what is the safe way to implement file upload in your server. Here is my situation..

    1. i want to let users upload small avatar like image files in the website.
    2. I tried setting upload folder 777 permission and i am afraid that it could be a serious security concern?
    3. i tried setting permissions to 755 or 775 , but upload fails.
    4. i am saving the images in the server and not storing in the database.

    what is the best way to do this? :)
     
    olddocks, Nov 16, 2007 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Here is my solution:

    Place the images in a directory below user access (under www/public_html), this way user's can't directory access files that might cause trouble.

    Access the images using a getimage.php file (which will be passed the name), which will check for security, file type and such.

    Peace,
     
    Barti1987, Nov 16, 2007 IP
  3. olddocks

    olddocks Notable Member

    Messages:
    3,275
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    215
    #3
    what permissions do i need to set?
    i heard this method, but i think i should fetch the file and read the image files using filesystem functions...

    If anybody could post sample code, it would be much helpful as i am more confused on this :confused:
     
    olddocks, Nov 16, 2007 IP