当我调用下面的WordPress unzip\\u file()函数时,它不是实际提取zip,而是将其移动到目标文件夹中。
当我从includes/file跟踪$file和$to时。php我得到:
file: C:\\xampplite\\htdocs\\testsite/wp-content/themes/mytheme/styles/myzip.zip
To: C:\\xampplite\\htdocs\\testsite/wp-content/themes/mytheme/styles/
我错过了什么?
<?php
require(\'../../../wp-blog-header.php\');
require(\'../../../wp-admin/includes/file.php\');
?>
<?php
if (!is_user_logged_in()){
die("You Must Be Logged In to Access This");
}
if( ! current_user_can(\'edit_files\')) {
die("Oops sorry you are not authorized to do this");
}
?>
<form enctype="multipart/form-data" action="" method="post">
<input type="file" name="fupload" /><br /><br />
<input type="submit" value="Install" onclick="doLoader();" />
</form>
<?php
if(isset($_FILES[\'fupload\'])) {
$filename = $_FILES[\'fupload\'][\'name\'];
$source = $_FILES[\'fupload\'][\'tmp_name\'];
$type = $_FILES[\'fupload\'][\'type\'];
$name = explode(\'.\', $filename);
$target = TEMPLATEPATH.\'/styles/\';
// permission settings for newly created folders
$chmod = 0755;
$saved_file_location = $target . $filename;
if (move_uploaded_file($source, $saved_file_location))
{
unzip_file($saved_file_location, $target);
}
else
{
die("There was a problem with the upload. Plese verify you have uploaded a valid zip file");
}
}
?>