using the PHP fonction [B]move_uploaded_file(..)[/B] is it possible to choose the name onder which you are storing the uploaded file on the destination directory?
Example: you upload from your PC the file [B]myfile.gif[/B] and on the destination direstion you use as name of the file [B]othername.gif[/B]
@pyroOct 19.2004 — #The destination filename is the second paramater of the [URL=http://www.php.net/manual/en/function.move-uploaded-file.php]move_uploaded_file[/URL] function. You can also take a look [URL=http://www.php.net/manual/en/features.file-upload.php]here[/URL] for more information on handling file uploads.
@faamugolauthorOct 19.2004 — #thank you very much for all your answers..
I want to be more clear.
When a visitor of my site wants to register , he can also upload his picture(photo). But I encourred the following problem. When a previous visitor has already register with the same name for his picture, the last one overwrites the first one.
Waht I need is the following:
When a visitor upload his picture, I make a test, if the filename already exists on the server, I juste add somes chars to the second, so to make a difference between the two picture.
@yunaOct 19.2004 — #Regardless of what the uploader calls the file, you need to be in control of how things are named on your server. The easiest solution would be to use the person's registered ID, since that has to be unique for other things to work correctly. So, for instance, if I register as "yuna" and upload "myphoto.jpg," you could store it as "yuna.jpg" and link to it accordingly.
I've even used Unix timestamps as filenames since they're so likely to be unique. There would be a conflict only in the case of two simultaneous submissions within the same second. None of the sites I've developed handle traffic at that rate of speed. Since all the person's information is in the database, it doesn't matter what I call the file. The database record makes the appropriate connections between the user and the filename I've chosen.
@dreamcatcherOct 19.2004 — #Another solution is to make the field that holds the photo name in your database UNIQUE. This will prevent duplications. When you do your SQL query, if it returns false, inform the user that the image already exists.