?

Search Help Board

PHP FAQ
PHP Articles
PHP Help
Bulletin Board

PHP Manual (NEW!)
First Time PHP'ers
Help with programming
Sql assignment help
PHP Homework Help


?
?Photo Upload
Author:??(---.nyc.rr.com)
Date:???02-16-04 22:13

At the moment I have the following code that uploads images to my server (see below). Prior to this code, I have a file form that allows me to "browse" for a file on my computer, then submit it, then this code runs.....

if ($file1)
{
$pathonserver = "D:\\INETPUB\\12345ABC\\image\\upload\\";
$fileonserver = $pathonserver."".$file1_name;
// BEGIN FILE UPLOAD
copy($file1, "$fileonserver");
unlink($file1);
$photo1 = $file1_name;
}

After the file is uploaded, I have my page update my table to store the image name ($photo1 is the variable that is stored in the table).

Now, here's what I want to do. At the moment, the "file_name" is whatever the file name was when I uploaded it. I do not want that. I want my code to rename the file. So, if I upload c:/image.jpg, I want the image renamed to....

$file_name=$rowid."_".$rowtitle;

This way, I can ensure all the images have different names and none copy over any other photos on the server. Basically, I'm not sure how to easily do this.... If I edit the name prior to the "$fileonserver" line, then the file doesn't get uploaded.

Any ideas?

?Topics Author? Date
?Photo Upload??new
Jabbamonkey 02-16-04 22:13?
?Re: Photo Upload??new
Jabbamonkey 02-17-04 06:58?
?Re: Photo Upload??new
bastien 02-17-04 09:08?
?Re: Photo Upload??new
redonia aljohn 10-25-04 16:33?
Go to Top??|??Go to Topic??|??Flat View??|??Search?
??|??
New Topic
?Reply To This Message
?Your Name:
?Your Email:
?Subject:
Email replies to this thread, to the address above.
??wrote: > > At the moment I have the following code that uploads images > to my server (see below). Prior to this code, I have a file > form that allows me to "browse" for a file on my computer, > then submit it, then this code runs..... > > if ($file1) > { > $pathonserver = "D:\\INETPUB\\12345ABC\\image\\upload\\"; > $fileonserver = $pathonserver."".$file1_name; > // BEGIN FILE UPLOAD > copy($file1, "$fileonserver"); > unlink($file1); > $photo1 = $file1_name; > } > > After the file is uploaded, I have my page update my table to > store the image name ($photo1 is the variable that is stored > in the table). > > Now, here's what I want to do. At the moment, the "file_name" > is whatever the file name was when I uploaded it. I do not > want that. I want my code to rename the file. So, if I upload > c:/image.jpg, I want the image renamed to.... > > $file_name=$rowid."_".$rowtitle; > > This way, I can ensure all the images have different names > and none copy over any other photos on the server. Basically, > I'm not sure how to easily do this.... If I edit the name > prior to the "$fileonserver" line, then the file doesn't get > uploaded. > > Any ideas? ">??

Provided By
Phorum