Re: Image Upload, renaming question
| From: | Joe Van Meer | Date: | Thu, 15 Nov 2001 20:21:43 +0000 |
| Subject: | Re: Image Upload, renaming question | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74781@lists.php.net to get a copy of this message | ||
Thx Richard, I would like the files to all be dumped into one directory,
each with a unique name. Then I will create a path and store that in the db.
Thx for the ideas, I will check them out and get back to youvia this thread.
Cheers Joe:)
"Richard Lynch" <ceo@l-i-e.com> wrote in message
news:200111160017.SAA08531@mail.developersfoundry.com...
> 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
>