views:

72

answers:

3

Warning: move_uploaded_file(/home/site/public_html/wp-content/themes/mytheme/upgrader.zip) [function.move-uploaded-file]: failed to open 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]: Unable to move '/tmp/phptempfile' to '/home/site/public_html/wp-content/themes/mytheme/upgrader.zip' in /home/site/public_html/wp-content/themes/mytheme/uploader.php on line 79 There was a problem. Sorry!

Code is below for that 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!");
}
+1  A: 

It seems that you will need to add write permissions to the folder that the zip file is being moved to. I am assuming you are using Linux and apache. You can change the owner of the upload folder to apache and give it 770 permissions. An INSECURE alternative is to not change the owner of the folder and change the permission to 777, which like I said is not secure.

The following article provides some more info in addition to some techniques to secure the second alternative I provided:

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

Waleed Al-Balooshi
A: 

If you have access to your server, have a look at you .htaccess file and php.ini folder to check what files are allowed to be uploaded. If you are hosting through a company, you should have access to an online control panel that has a php settings section.

Yo Momma
A: 

Try to use the chmod function before the move script, and add write permission to that folder.

LucaB