php - Drupal 7 failed to open stream: Permission denied in image_gd_save() -
i trying generate , scaled image thumbnails, scaling image has no problem , when use
image_save($_image) // works fine
(using same folder replacing) code has not problem, problem starts when tried save images in destination folder using destination parameter:
image_save($_image, $destination) //throws errors
then error occurs:
warning: imagejpeg(c:\xampp\htdocs\drupal-devel\sites\default\files): failed open stream: permission denied in image_gd_save() (line 284 of c:\xampp\htdocs\drupal-devel\modules\system\image.gd.inc).
i'm working windows xampp , using function is_write
of php, return true, no problem permissions.
i had been trying time , don't know what's happening, no problem permissions.
this code:
$destination = 'public://gallery/thumbs/'; $filepath = drupal_get_path('module', 'gallery_blueprint') . '/img/large/1.jpg' // someplace before function file_prepare_directory($destination, file_create_directory); _generate_thumb($filepath,$destionation,300,null); // function code function _generate_thumb($filepath, $destination_path, $width = null, $height = null) { $_img = image_load($filepath); $scaled = image_scale($_img, $width, $height); // return true $result = image_save($_img, $destination_path); //error occurs whit destination path return $result; }
is stupid answer written.
the function image_save()
when pass throw $destination folder, doesn't write name default, need write final absolute name path, name of file required or throws.
warning: imagejpeg(c:\xampp\htdocs\drupal-devel\sites\default\files): failed open stream: permission denied in image_gd_save() (line 284 of c:\xampp\htdocs\drupal-devel\modules\system\image.gd.inc). //finally need write whole filepath image_save($_img, $finalname_path) //$filname_path = public://gallery/thumbs/1.jpg
Comments
Post a Comment