2011-01-29 9 views
0

아래 함수가 실행될 때, 나는 ... 얻고 있습니다. 치명적인 오류 : 'ZipArchive'클래스가 /home/test/dummyurl.com에 없습니다. 줄에 /wp-content/themes/mytheme/upload-zip.php 14치명적인 오류 : 'ZipArchive'클래스가 없습니다. (PHP 5.3.1)

PHP 버전이이 워드 프레스 응용 프로그램에 5.3.1

function openZip($file_to_open) { 
    global $target; 
    $zip = new ZipArchive(); //This is line 14 
    $x = $zip->open($file_to_open); 
    if($x === true) { 
    $zip->extractTo($target); 
    $zip->close();  
    unlink($file_to_open); 
    } else { 
    die("There was a problem. Please try again!"); 
    } 
} 

이고, 나는 아마 할 수있을 것 같아요 내장 함수 (아래 참조)를 사용하지만 위의 ZipArchive 클래스가없는 이유를 아직 모릅니다 ...

/** 
    * Unzip's a specified ZIP file to a location on the Filesystem via the WordPress Filesystem Abstraction. 
    * Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present. 
    * 
    * Attempts to increase the PHP Memory limit to 256M before uncompressing, 
    * However, The most memory required shouldn't be much larger than the Archive itself. 
    * 
    * @since 2.5.0 
    * 
    * @param string $file Full path and filename of zip archive 
    * @param string $to Full path on the filesystem to extract archive to 
    * @return mixed WP_Error on failure, True on success 
    */ 
function unzip_file($file, $to) { 
    global $wp_filesystem; 

    if (! $wp_filesystem || !is_object($wp_filesystem)) 
    return new WP_Error('fs_unavailable', __('Could not access filesystem.')); 

    // Unzip can use a lot of memory, but not this much hopefully 
    @ini_set('memory_limit', '256M'); 

    $needed_dirs = array(); 
    $to = trailingslashit($to); 

    // Determine any parent dir's needed (of the upgrade directory) 
    if (! $wp_filesystem->is_dir($to)) { //Only do parents if no children exist 
    $path = preg_split('![/\\\]!', untrailingslashit($to)); 
    for ($i = count($path); $i >= 0; $i--) { 
    if (empty($path[$i])) 
    continue; 

    $dir = implode('/', array_slice($path, 0, $i+1)); 
    if (preg_match('!^[a-z]:$!i', $dir)) // Skip it if it looks like a Windows Drive letter. 
    continue; 

    if (! $wp_filesystem->is_dir($dir)) 
    $needed_dirs[] = $dir; 
    else 
    break; // A folder exists, therefor, we dont need the check the levels below this 
    } 
    } 

    if (class_exists('ZipArchive') && apply_filters('unzip_file_use_ziparchive', true)) { 
    $result = _unzip_file_ziparchive($file, $to, $needed_dirs); 
    if (true === $result) { 
    return $result; 
    } elseif (is_wp_error($result)) { 
    if ('incompatible_archive' != $result->get_error_code()) 
    return $result; 
    } 
    } 
    // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file. 
    return _unzip_file_pclzip($file, $to, $needed_dirs); 
} 

답변

0

당신은 PHP의 확장자를

1) php_zip를 활성화해야

2)

을 php_zlib_filters
관련 문제