unzip_file将文件移动到目标位置但不提取它?

时间:2011-02-01 03:59:45

标签: php file-upload

当我调用下面的unzip_file()函数时(包含在wordpress /../ wp-admin.includes / file.php中),而不是实际提取zip,它只是将其移动到目标文件夹中。

当我从includes / file.php跟踪$ file和$ to时,我得到:

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

0 个答案:

没有答案