duandanxiu6965 2010-02-23 12:23
浏览 32
已采纳

这段代码有什么问题:来自远程压缩文件的file_get_contents和解压缩到本地目录

The purpose of this code is to pull upgrade.zip from a central server, extract it and place it in a folder on the resident server. I get no errors, it just results in the die("!There was a problem. Please try again!");

require('../../../wp-blog-header.php');

function openZip($file_to_open) { 
    global $target;  
    $zip = new ZipArchive();  
    $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!");  
    }  
} 

$payload = file_get_contents('http://myserver.com/upgrade.zip');
if(isset($payload)) 
    {
    $filename = 'upgrade.zip';
    $source = file_get_contents('http://myserver.com/upgrade.zip');
    $target = ABSPATH.'wp-content/themes/mytheme/';

    // permission settings for newly created folders
    $chmod = 0755;  

    $saved_file_location = $target . $filename;

openZip($saved_file_location);

}
  • 写回答

2条回答 默认 最新

  • douwu8524 2010-02-23 12:31
    关注

    You get the contents of the remote zip file into a string... but you never save it anywhere.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大