Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image permissions after uploading for resize

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

like image 574
shruti Avatar asked Oct 21 '13 11:10

shruti


1 Answers

You need to run this on the files:

chmod ($filepath, 0777);

in your case probably:

chmod("$upload_dir/$names",0777);
like image 98
Sunny R Gupta Avatar answered Oct 14 '22 03:10

Sunny R Gupta