问题
I am having a user's profile page in which user uploads his profile picture from file dialog..
when the file is moved to my local server's folder it gets permission as 0644 only..
but I want to resize this image before getting uploaded into server...
And for this I need permission as 0777 to edit it...
How should I do it..
here is my code for move and resize
$upload_dir = './images';
$tmp = $_FILES["img"]["tmp_name"];
$names = $_FILES["img"]["name"];
$res=$moveR=move_uploaded_file($tmp, "$upload_dir/$names");
$a="./images/".$names;
list($width, $height) = getimagesize($a);
$newwidth = "300";
$newheight = "200";
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($a);
imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb, $a, 100);
Thanks in advance..
回答1:
You need to run this on the files:
chmod ($filepath, 0777);
in your case probably:
chmod("$upload_dir/$names",0777);
回答2:
add this code with your absolute path
$file_path = $path.'/files/ChatRequestXML/'.$profile_id.'.jpg'; // change with your actual path
chmod($file_path, 0777);
hope this will sure help you
回答3:
you need to add this line after move_uploaded_file function to set 777 permission for the uploaded file
<?php
exec("chmod $upload_dir/$names 0777");
?>
来源:https://stackoverflow.com/questions/19492932/image-permissions-after-uploading-for-resize