下面是我用来在一个文件夹中添加图像到zip archieve的代码,但它不起作用,我不明白我得到的所有时间我的屏幕中的followng ierogliphics请帮助 在此先感谢。
<?php
//download_all_images_view_searches_page.php
include_once('site_constants.php');
include_once('library_functions.php');
include('connection.php');
include ('db_picinfo_search_functions.php');
$output_folder = rawurldecode($_GET['output_folder']);
echo "<script>alert('".$output_folder."');</script>";
$array=download_all_images_as_zip($output_folder);
$array_of_images=[];
foreach($array as $add_image_to_array){array_push($array_of_images, $add_image_to_array );}
$zip = new ZipArchive();// create object
$zip = new ZipArchive();# create new zip opbject
$tmp_file = tempnam('.','');# create a temp file & open it
$zip->open($tmp_file, ZipArchive::CREATE);
foreach($array_of_images as $file)# loop through each file
{
$bn=basename($file);
echo "<a href='".$file."' download>$bn</a><br/>";
$download_file = file_get_contents($file);# download file
//echo "<script>alert('".$bn."');</script>";
$zip->addFromString($bn, $download_file);#add it to the zip
}
$zip->close();# close zip
$zip_name = time().".zip";#give a name to the zip
header('Content-Disposition: attachment; filename="'.$zip_name.'"');# send the file to the browser as a download
header('Content-type: application/zip');
readfile($tmp_file);
?>
答案 0 :(得分:0)
您的问题是您在输出文件之前输出文本。从代码中删除每个echo命令。