Когда я вызываю приведенную ниже функцию unzip_file () (содержится в wordpress /../ wp-admin.includes / file.php), вместо того, чтобы фактически извлечь zip, он просто перемещает его в целевую папку.
Когда я отслеживаю $ file и $ to из include / file.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");
}
}
?>