Re: renaming uploaded files
| From: | Joe Van Meer | Date: | Sat, 02 Feb 2002 23:24:11 +0000 |
| Subject: | Re: renaming uploaded files | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16452@lists.php.net to get a copy of this message | ||
Hi there, you could grab the whole file name from db, form, etc... strip it
down to the '.jpg' , concatenate $IDNUMBER . $NUMBER OF PICTURE , then
rename it using the combination of $IDNUMBER . $NUMBER OF PICTURE .
<?php
$myfile = 'webgraphic.jpg';
$IDNUMBER = 55;
$NUMBEROFPICTURE = 999;
if(isset($myfile)){
$newfilename = $IDNUMBER . $NUMBEROFPICTURE ;
//grab the dot and the file extension
$myfile = substr($myfile, -4);
$myfile = $newfilename . $myfile;
echo $myfile;
//upload process follows
}
?>
Jose Maria Sala <jmsala@airredes.com> wrote in message
news:20020131202420.33390.qmail@pb1.pair.com...
> Hi php developers:
>
> I have created a website for a house renting company with an
administration
> tool. Using this tool, managers can add, modify and delete data in a mysql
> database.
>
> They can also upload some pictures of the houses they rent. The way i do
> this is by taking them to the list of houses, making them select one and
> next they go to a form. In this form they upload files to a certain folder
> in the server.
>
> What i would like to do is auto rename the file with a name composed by
> IDNUMBER + NUMBER OF PICTURE (ex. if ID of that house is 345 image name
> would be 34501.gif, 34502.gif, 34503.gif,...)
>
> I think you got the idea. Any help would be greatly appreciated.
>
> thx in advance
>
>