Forgot to post to the whole list! sorry....

-----Original Message-----
From: matt stewart 
Sent: 01 February 2002 09:22
To: 'Jose Maria Sala'
Subject: RE: [PHP-DB] renaming uploaded files


Hi Jose - this has a bit of error checking with it too.
this just uploads one file with the name 345.jpg for example.
you may want to do something to produce a number such as 000345 (will allow
up to 999999 houses on the database) as this will then make adding 3 images
for the house easier to search for - you can find all images starting with
000345 as opposed to two images 3451, and 34511 (the first image of house
345, and the first image of house 3451!).
For some reason i never manage to write a script which uploads more than one
image at a time, so maybe if you can, you could let me see the code, or if
not, just loop through this uploads page, passing $Pic_Number and
incrementing it each time?
Hope this helps.

Matt

Here's the code:

if ($Image=="none"){
        echo "Problem: no file uploaded";
        exit;
}

if (($Image_type != "image/gif")&&($Image_type !=
"image/jpeg")&&($Image_type != "image/pjpeg")){
        echo "Problem: file is not an image, type is $Image_type";
        exit;
}

if (!is_uploaded_file($Image)){
        echo "Problem: possible file upload attack";
        exit;
}

if ($Image_size == 0){
        echo "Problem: Image has zero size";
        exit;
}
if ($Image_type=="image/gif"){
        $upfile =
"/home/httpd/vhtdocs/mywebsite/images/uploads/".$House_ID.$Pic_Number.".gif"
;
}elseif (($Image_type=="image/jpeg")||($Image_type=="image/pjpeg")){
        $upfile =
"/home/httpd/vhtdocs/mywebsite/images/uploads/".$House_ID.$Pic_Number.".jpg"
;
}

if (!copy($Image, $upfile)){
        echo "Problem: Could not move file into directory";
        exit;
}
echo "File uploaded successfully<br><br>";

-----Original Message-----
From: Jose Maria Sala [mailto:[EMAIL PROTECTED]]
Sent: 31 January 2002 20:24
To: [EMAIL PROTECTED]
Subject: [PHP-DB] renaming uploaded files


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



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.319 / Virus Database: 178 - Release Date: 28/01/02
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.319 / Virus Database: 178 - Release Date: 28/01/02
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.319 / Virus Database: 178 - Release Date: 28/01/02
 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to