Re: Image Upload, renaming question
| From: | Richard Lynch | Date: | Thu, 15 Nov 2001 20:16:14 +0000 |
| Subject: | Re: Image Upload, renaming question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74778@lists.php.net to get a copy of this message | ||
Joe Van Meer wrote:
> Hi there, I have an upload form on my website that works great, however I
> have come to a roadblock...how the heck do I rename the copied file?
> Everytime I upload an image it overwrites the old one with the new. The
> code below uploads the file and displays the following:
>
> Your photo has been uploaded successfully.
> Size of Image in Bytes: 36315
> Image Type: image/pjpeg
> File exists on server.
> /rotatingimages/C:\PHP\uploadtemp\php12D.tmp <-- I notice that this is a
> temporary name
If two files were being uploaded at once, you'd get two different names...
But it's entirely up to *YOU* to decide where to copy the file to. Maybe
you'd *WANT* to replace files as they were uploaded.
I tend to use the user's filename and preg_replace() to get rid of
everything except a-zA-Z._- and then checking where I'm copying to tack on
1, 2, 3, ... until I find a new filename that's not in use.
You should also start using http://php.net/move_uploaded_file instead of
copy or whatever you are doing.
--
Like music? http://l-i-e.com/artists.htm