上传后调整图像权限 [英] Image permissions after uploading for resize

查看:155
本文介绍了上传后调整图像权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户的个人资料页面,其中用户从文件对话框上传他的个人资料图片。

I am having a user's profile page in which user uploads his profile picture from file dialog..

当文件移动到我的本地服务器的文件夹时,它获得了权限仅限0644 ..

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...

为此,我需要获得0777的许可才能编辑它...

And for this I need permission as 0777 to edit 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);

提前致谢..

推荐答案

你需要在文件上运行:

chmod ($filepath, 0777);

在您的情况下可能:

chmod("$upload_dir/$names",0777);

这篇关于上传后调整图像权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆