Jump to content

upload file


dannybrazil

Recommended Posts

Why do we change the name? We usually attach an ID tag to the name so that we don't overwrite a file that has the same name.

 

Say I upload a picture of Australia with the name "country.jpg", and then one of South Africa called "country.jpg". The South Africa photo would overwrite the Australia photo. So instead, I'd upload the first one and my script would change it to "1 country.jpg" and the South Africa photo would be changed to "2 country.jpg" but that's just me. I like to store uploaded files into a database and append their ID to the beginning of their name

Link to comment
https://forums.phpfreaks.com/topic/174343-upload-file/#findComment-919010
Share on other sites

There is also a security reason aswell. If you allow people to upload files with names they wish they maybe able to overwrite previous files. (Filename = "../../../../etc/passwd") If you allow them to upload any old type of file they could upload a copy of a php shell and then just type in the url and do whatever they want with your web page. (Depending on your set up) Personally I use "{$FileID}{$FileNameHash}.{$FileType}" as my file naming system.

Link to comment
https://forums.phpfreaks.com/topic/174343-upload-file/#findComment-919055
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.