0
ファイルを圧縮するためにダウンロードボタンを作成しようとしました。配列内に複数のファイルを設定すると、エラーが発生します。PHPは複数のファイルをZIPエラーとしてダウンロードします
"files/path/to/8717953176714.jpg"をハードコードすると動作します。
<?php
//print_r($_POST["foto"]);
$files = array($_POST["foto"]);
$random = rand(1000000000, 9999999999);
$zipname = 'file'.$random.'.zip';
$zip = new ZipArchive;
$zip->open($zipname, ZipArchive::CREATE);
foreach ($files as $file) {
$zip->addFile($file);
}
$zip->close();
$filename = $zipname;
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-length: ' . filesize($filename));
readfile($filename);
$file = fopen('iplog.txt', 'a', 1);
$ipz = getenv("REMOTE_ADDR");
$text = "$ipz\n";
fwrite($file, $text);
fclose($file);
?>
の
私には何も与えません。は動作しません:( – Horizon
echo $ zipname;パスがOKかどうかを確認します –