Image resolution after upload to resize

I have a user profile page in which the user loads his profile picture from the file dialog box.

when a file is moved to the local server folder, it only gets permission from 0644.

but I want to resize this image before uploading to the server ...

And for this I need permission like 0777 to edit it ...

How can I do it.

here is my code for moving and resizing

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

+6
source share
3 answers

You need to run this in the files:

 chmod ($filepath, 0777); 

in your case, probably:

 chmod("$upload_dir/$names",0777); 
+1
source

add this code with absolute path

  $file_path = $path.'/files/ChatRequestXML/'.$profile_id.'.jpg'; // change with your actual path chmod($file_path, 0777); 

Hope this helps you.

0
source

you need to add this line after the move_uploaded_file function to set the resolution to 777 for the downloaded file

 <?php exec("chmod $upload_dir/$names 0777"); ?> 
0
source

Source: https://habr.com/ru/post/956403/


All Articles