Reputation: 279
I get the following error when writing a thumbnail image to the below directory
Warning: imagejpeg() [function.imagejpeg]: Unable to open 'D:\imagesdb\images\62t\' for writing: No such file or directory
if I manually create a directory and then add that to imagejpeg() for example: C:\images I get the same error, this also applies if I use fopen
Warning: fopen(C:\images\) [function.fopen]: failed to open stream: No such file or directory
All paths exsist! I have also checked the varibles to see if the paths are correct and I am not loosing data, (var_dump!)
I have also tried chmod, but I am using windows and this should not apply?
I am using
Windows XP Home Edition SP3 running localhost, XAMMP, apache, php
I am worried if it the OS version I am using, I have tried giving the apache service local system account access in 'services', tried sharing the folder!
I can write a normal images on upload to another folder 'images\62' in the same dirctory, however 'images\62t' either has permission denied, or does not exist when I try and write a thumb?
I have checked php.ini, gd is enabled and I have tried un-commenting: extension=php_gd2.dll , safe-mode is also off.
I am worried if it is my OS version, it's very limited where file permissions are concerned? Or is it just my code?
if($this->changed){
//$tp = fopen("C:\images\\",'w+');
chmod($this->thumb_path, 0777);
$originalImage = imagecreatefromjpeg($this->image_path);
$width = imagesx($originalImage);
$height = imagesy($originalImage);
$thumb_width = $this->thumbWidth;
$thumb_height = floor($height * ($this->thumbWidth / $width));
$newImage = imagecreatetruecolor($thumb_width,$thumb_height);
imagecopyresized($newImage,$originalImage, 0, 0, 0, 0, $thumb_width, $thumb_height, $width, $height );
imagejpeg($newImage,$this->thumb_path);
} else {
$this->_messages[] = $field['name' ] . 'did not upload please check and try again' ;
}
Upvotes: 2
Views: 17936
Reputation: 1607
$image_path=getcwd()."/your_images_directory/yourfile.jpg";
chmod your directory to 775 or whatever feeds your requirements.
This stack have suggestions for the permissions
Upvotes: 1
Reputation: 167
try to put the relative path instead of putting the absolute path in imagejpeg, at least that's how I resolve that problem.
Upvotes: 3
Reputation: 32701
$this->thumb_path
probably only contains a path without a filename. Without a filename: How should PHP know how to name the file?
Upvotes: 6