Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- PHP File upload - rename file
December 14, 2004, 5:00 am
rate this thread
I have to allow my visitors to upload image on my site.
I am using the follwoing code to do that:
$uploaddir = 'admin/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
My problem is that I expect them to use same file name, like all of
them will be uploading files like, comments.rtf. So if there is already
one comments.rtf the file will get overwriten... so the challenge is to
rename the files to username-filename.rtf
can anybody here will take the pain to modify this code, I will be
thankful, or please guide to me some tutorial where they are dealing
with simple code and not with advanced classes.
Thank you in advane
Re: PHP File upload - rename file
email@example.com contained the following:
Is the username unique? If so it's just
$uploadfile = $uploaddir.
Though you might like to add a character for neatness
$uploadfile = $uploaddir .
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker /