I'm making a website in which users will be able to upload files. All files are stored in the same location, so I'm currently generating a unique filename for each in order to avoid saving files with the same name. I'm also storing the original filename in the DB.
When the user wants to download there file, I'm retrieving the unique filename and this is the name of the file that they download (as in the "Save as" dialog the browser shows).
Is it possible to have the original name as the "Save as" dialog default?
One idea I had was to copy the file to the temp folder using the original filename and then have the user download that, but technically speaking there could be a situation in which two files with the same original filename are attempted to be downloaded at the same time and one overwrites the other and one user downloads the other's file.
If it's relevant, I'm using PHP.
Thanks
Yes, it's possible. You should use the Content-Disposition
HTTP header. Take a look at the documentation here.
header('Content-Disposition: attachment; filename="' . $original_filename . '"');