douxi1968 2016-01-22 19:20
浏览 55

添加swf文件时,压缩zip文件

im trying to download swf files from the urls, from number 1752 to number 1760. I made a code and everything seem ok but the files are broken! their size are 0 and they are empty! (the swf files) I dont know what is wrong with my code. here's my code:

<?php 

$num = 1753;
$files = array('');
while($num !== 1760){
array_push($files, '');
$num++;
}
print_r($files);
    $zip = new ZipArchive();

$tmp_file = tempnam('.','');
$zip->open($tmp_file, ZipArchive::CREATE);

foreach($files as $file){

    $download_file = file_get_contents($file);

    $zip->addFromString(basename($file),$download_file);

}

$zip->close();

header('Content-disposition: attachment; filename=Resumes.zip');
header('Content-type: application/zip');
readfile($tmp_file);
?>

help?

  • 写回答

2条回答 默认 最新

  • douchunxian9740 2016-01-22 19:26
    关注

    The server does not have a file called $num.swf, you're getting a 404 error.

    You need to use double quotes if you want PHP to interpolate the variable into its value.

    while($num !== 1760){
        $files[] = "mogobe.walla.co.il/Swf/AssetsClean/Items/IconS/$num.swf";
        $num++;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入