What causes this permission error and how can I get around it?

Warning: move_uploaded_file (/home/site/public_html/wp-content/themes/mytheme/upgrader.zip) [function.move-uploaded-file]: could not open the stream: Permission denied in / home / site / public_html / wp- content / themes / mytheme / uploader.php on line 79

Warning: move_uploaded_file () [function.move-uploaded-file]: Cannot move '/ tmp / phptempfile' to '/home/site/public_html/wp-content/themes/mytheme/upgrader.zip' to / home / site / public _html / wp-content / themes / mytheme / uploader.php on line 79 There was a problem. Sorry!

The code below for this line ...

// permission settings for newly created folders $chmod = 0755; // Ensures that the correct file was chosen $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/s-compressed'); foreach($accepted_types as $mime_type) { if($mime_type == $type) { $okay = true; break; } } $okay = strtolower($name[1]) == 'zip' ? true: false; if(!$okay) { die("This upgrader requires a zip file. Please make sure your file is a valid zip file with a .zip extension"); } //mkdir($target); $saved_file_location = $target . $filename; //Next line is 79 if(move_uploaded_file($source, $saved_file_location)) { openZip($saved_file_location); } else { die("There was a problem. Sorry!"); } 
+4
source share
3 answers

It seems you will need to add write permissions to the folder where the zip file is being moved. I assume you are using Linux and apache. You can change the owner of the downloaded folder on apache and give it 770 permissions. An alternative to INSECURE is not changing the owner of the folder and changing the permission to 777, which, as I said, is not safe.

The following article provides additional information in addition to some methods of protecting the second alternative that I have provided:

http://www.mysql-apache-php.com/fileupload-security.htm

+1
source

If you have access to your server, look at the .htaccess file and the php.ini folder to see which files are allowed to be downloaded. If you take part in the company, you should have access to the online control panel, which has a php settings section.

0
source

Try using the chmod function before moving the script and add write permissions to this folder.

0
source

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


All Articles