shr*_*uti 6 php permissions image file chmod
我有一个用户的个人资料页面,用户从文件对话框上传他的个人资料图片.
当文件移动到我的本地服务器的文件夹时,它只获得0644的权限..
但我想在上传到服务器之前调整此图像的大小...
为此我需要0777的许可来编辑它...
我应该怎么做..
这是我移动和调整大小的代码
$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);
Run Code Online (Sandbox Code Playgroud)
提前致谢..
您需要对文件运行以下命令:
chmod ($filepath, 0777);
Run Code Online (Sandbox Code Playgroud)
在你的情况下可能:
chmod("$upload_dir/$names",0777);
Run Code Online (Sandbox Code Playgroud)