Results 1 to 4 of 4

Thread: Why should you change the name of the image uploaded?

  1. #1
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Why should you change the name of the image uploaded?

    Hey all,
    I recently found a script that works great for allowing users to upload pictures. It changes the uploaded file name though... here's the script:

    http://www.reconn.us/file_uploading.html

    I'm just curious why is this helpful or needed? Is this a good thing or a bad thing or does it even matter?

    Just curious.

    -Sammy

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    It mostly depends on the use of the code. If you are using it for a forum (or even an image hosting site), it would be wise to append to the file name something like the unix timestamp or a random hash. This is mainly due to the possiblity of users uploading the same image mulitple times (without knowing it).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Well, you should check for duplicates in many cases and just only keep one, but link to that same file for both additions to the system, if needed. This depends on your use of an image uploader, though.

    Changing the filename prevents duplicate names of even different pictures, like "pic1.jpg" which could be ANYTHING, and likely will overlap, given enough users.

    Also, changing the name of uploaded files can help in security, in case someone uploads a script that is dangerous, they can't find it so easily. However, this isn't the only protection that is needed, and doesn't apply if you are only doing images.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jan 2007
    Posts
    94
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Yeah, i totally didn't think of some of those things... thanks for answering my question!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •