I have a php files, name image_creat.php
$res = mysql_query("select * from images where key!='en' Order By id DESC LIMIT 0,10");
while ($rows = mysql_fetch_array($result))
{
$imageurl = dirname(__FILE__) . '/../images/';
$width = $row['width'];
$height = $row['height'];
$source_image = @imagecreatefromjpeg($row['image']);
$desired_width = '800';
$desired_height = floor($height*($desired_width/$width));
$virtual_image = @imagecreatetruecolor($desired_width,$desired_height);
@imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
@imagejpeg($virtual_image,$imageurl,'100');
}
I use SSH to setting the permission for it:
chmod 0755 /var/www/html/php/image_creat.php
chown root:root /var/www/html/php/image_creat.php
Then also setting permission for the images folder:
chmod 0755 /var/www/html/php/images/
But after the php script create jpeg files, I find all the files with permission of 644, so that my browser refused to visit it. where is the problem? Thanks.
ls -lfor both the images folder and some of its contents? We need to know the owner user and group. – Khaled Jan 23 '12 at 15:45chmod("path/to/image.jpeg", 0755);As for the why - the user your php scripts run as is determined by the web server (e.g apache with mod_php will usually be apache or www-data; php-fpm will be based on the pool, etc) - this determines the owner, and the umask of that user determined the permissions of newly created files. That said, 644 should be readable (although, some setups do require execute permissions on php files, they shouldn't be needed on images). – cyberx86 Jan 23 '12 at 17:01