Page 1 of 1

Image not being saved to folder

Posted: Thu Nov 18, 2004 9:10 am
by phpnew
Hi All

I have been trying to get around this problem but with no respite. One of the old programmers had written the code which identifies the image being loaded manupilates its name and saves it into a folder.

It does not work when I am trying and I have no idea as to what is happening the code looks ok. but does not give which folder to save in or I don't know if something needs to be added

I am posting the bit of code

PHP CODE
if (is_uploaded_file($property_image)) {
// there was a file uploaded with the product
$image_properties = getimagesize($property_image);
if ($image_properties) {
// the file was a valid image
$image_width = $image_properties[0];
$image_height = $image_properties[1];
$new_width = 175;
if ($image_width > $new_width) {
// the image is too big, so we must resize it
$ratio = $new_width / $image_width;
$new_height = $image_height*$ratio;
$image = ImageCreateFromJPEG($property_image);
$new_image = ImageCreateTrueColor($new_width, $new_height);
ImageCopyResized($new_image,$image,0,0,0,0,$new_width,$new_height,$image_width,$image_height);
ImageJPEG($image, $property_image);
}
$query = "SELECT MAX(id) AS id FROM houses";
$result = db_query($query, $db_connection);
$result = mysql_fetch_array($result);
$id = $result["id"];
$image_name = "/pictures/property_".$id;
if ($image_properties[2] == 1) $image_name .= ".gif";
elseif ($image_properties[2] == 2) $image_name .= ".jpg";
elseif ($image_properties[2] == 3) $image_name .= ".png";
copy($property_image, $image_name);
}
}
PHP CODE

Please help
Thank You

Posted: Thu Nov 18, 2004 11:51 am
by Shendemiar
On some setups on a multiuser server php can't save to ftp made directories, even if the permissions would allow it. Check folder owners.

Posted: Thu Nov 18, 2004 12:42 pm
by phpnew
Hi Shendemiar

Thank you for your response. I would like to know what should one do in the case you have mentioned. and how to solve it.

Please advice
Thank you

Posted: Fri Nov 19, 2004 1:20 am
by Shendemiar
I personally removed the feature to create directories from my php-made upload-manager and created ~450 directories by script on my computer and then uploaded them all via ftp. Voila, i had all the directories i needed and to these folders i could upload via php. I was in happy situation since i had static sturture that needs no deleting or creating folders.