-
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
-
-
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.
-
-
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
-
-
Yeah, i totally didn't think of some of those things... thanks for answering my question!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks