2016-01-22 33 views
1

我嘗試從網址下載的SWF文件,從數1752至1760號我 做了一個代碼,一切看起來正常,但該文件被破壞!它們的大小爲0,他們是空的! (在SWF文件) 我不知道什麼是錯我的代碼。 這裏是我的代碼:空文件加入SWF文件時

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

幫助?

回答

2

的服務器沒有一個叫$num.swf文件,你得到一個404錯誤。

如果您希望PHP將變量內插到其值中,則需要使用雙引號

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

仍然是空的SWF文件... – Motimot

2

您忘記了協議前綴以及變量插值(如Rocket Hazmat的回答)。

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

我固定它,但它仍然顯示我空的SWF文件 – Motimot

+0

哎呀,我甚至沒有注意到通過'http://'失蹤!好決定。 –

+0

NVM,它的工作!非常感謝!!你讓我今天一整天都感覺很好 :) – Motimot