Image not being saved to folder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpnew
Forum Newbie
Posts: 18
Joined: Tue Oct 12, 2004 7:40 am

Image not being saved to folder

Post 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
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post 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.
phpnew
Forum Newbie
Posts: 18
Joined: Tue Oct 12, 2004 7:40 am

Post 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
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post 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.
Post Reply