On Sat, 11 May 2002, Thomas Edison Jr. wrote:
> If i have a filename "room.jpg" in my Upload
> Directory, and someone else comes and uploads a file
> by the same name, the previous "room.jpg" is
> overwritten by the new one. Any suggestions?
In the long run, I think the best plan is to name your files after the
unique database ID.
Store the names ('room.jpg') in the database.
If you expect getting more than a thousand files or so, split them into
directories. If you use a numeric key, just take the last digit or two and
use that for the directory (for instance, '4745' would go in '5/4745').
Then write a simple readfile script to process downloads (see today's
thread about protecting downloads).
You can look in the database and construct URLs like:
and your download script can look at the number to figure out which
directory it's in, and look at the file name to figure out the mime type
to send. The browser's happy because it thinks it's getting a file called
room.jpg no matter how many of them you have, the server is happy because
the files are spread nicely across a few directories, you're happy because
you got your work done, and I'm happy because you sent me a British
Airways gift certificate out in gratitude.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php