What's causing this permission's error and how can I work around it?

Posted by Scott B on Stack Overflow See other posts from Stack Overflow or by Scott B
Published on 2010-03-17T02:22:01Z Indexed on 2010/03/17 4:01 UTC
Read the original article Hit count: 228

Filed under:
|

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!");
}

© Stack Overflow or respective owner

Related posts about php

Related posts about permissions