Re: Rename an upload
| From: | Jason Wong | Date: | Wed, 11 Dec 2002 09:43:52 +0000 |
| Subject: | Re: Rename an upload | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-127776@lists.php.net to get a copy of this message | ||
On Wednesday 11 December 2002 17:30, Steve Jackson wrote:
> I'm trying to rename an uploaded file with the value of a select I have
> in the uploaded form. Can someone point me in the right direction. The
> PHP.net rename manual isn't helping a lot? My code:
What is the problem?
> //eshop_upload.php
> <?php
> // Upload the picture to the selected directory and rename the file as
> the category number.
> if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
> {
>
>
> copy($HTTP_POST_FILES['userfile']['tmp_name'],"http://www.violasystems.c
> om/images/");
You've copied the uploaded file to another directory ...
> rename("($HTTP_POST_FILES['userfile']['tmp_name'])",
> "$category");
... but now you're renaming the [temporary] uploaded file? Shouldn't you be
renaming the above copied file?
In fact you should be able to do it in a single step by copying the uploaded
file to its new destination and new filename.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Age before beauty; and pearls before swine.
-- Dorothy Parker
*/