Image not being saved to folder
Posted: Thu Nov 18, 2004 9:10 am
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
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