我有多个图像,并打包到zip文件中以下载图像。当我单击下载时,zip文件大小为404字节,并且zip文件崩溃。什么问题使我的zip文件崩溃了 file download zip file
public function download_order_zipped_files() {
$this->data['kode_order'] = $this->GET('kode_order', true);
if (!isset($this->data['kode_order']))
{
echo('kok gaada');
exit;
}
$this->load->model('order_m');
$this->data['order'] = $this->order_m->get_row(['kode_order' => $this->data['kode_order']]);
$zipname=$this->data['kode_order']."_".$this->data['order']->nama_penerima."_".$this->data['order']->waktu_order.".zip";
if ( $this->POST( 'download' ) ) {
$files = $this->POST( 'files' );
# create new zip opbject
$zip = new ZipArchive();
# create a temp file & open it
$tmp_file = tempnam('.','');
$zip->open($tmp_file, ZipArchive::CREATE);
# loop through each file
foreach($files as $file){
# download file
$download_file = file_get_contents($file);
#add it to the zip
$zip->addFromString(basename($file),$download_file);
}
# close zip
$zip->close();
# send the file to the browser as a download
header('Content-disposition: attachment; filename="'.$zipname.'"');
header('Content-type: application/zip');
readfile($tmp_file);
}