[英]Download Zip file corrupted in codeigniter
我正在使用此功能來創建和下載 ZIP 文件。 我測試過,它適用於小於 200MB 的文件。 當我嘗試下載超過 250MB 的文件時,下載部分停止,打開時顯示已損壞。
public function download_songs($bs_id){
// public function download_songs(){
$this->load->library('zip');
$this->load->helper('file');
$this->load->helper('download');
// $bs_id = $this->input->post('bs_id');
$bsl_data = $this->public_model->get_result_array_with_one_where('buy_song_list','psl_bs_id',$bs_id);
$bal_data = $this->public_model->get_result_array_with_one_where('buy_album_list','bal_bs_id',$bs_id);
$d_type = 0;
foreach($bsl_data as $bs_row){
$dateA = $bs_row['psl_created'];
// your second date coming from a mysql database (date fields)
date_default_timezone_set('Asia/Kolkata');
$dateB = date("Y-m-d H:i:s");
$timediff = strtotime($dateB) - strtotime($dateA);
//if($timediff>10800){ // echo 'more than 3 hours';
if($timediff > 86400){ //echo 'more than 24 hours';
$this->db->where('psl_mml_id',$bs_row['psl_mml_id'])
->set('psl_status','1')
->update('buy_song_list');
$d_type = 0;
}
else{
// echo 'less than 3 hours';
if($bs_row['psl_status']=='0'){
$mml_data = $this->public_model->get_result_array('music_mp3_list','','','mml_id',$bs_row['psl_mml_id']);
if($bs_row['psl_file_type']=='MP3'){
$f = $mml_data['mml_mp3'];
}
if($bs_row['psl_file_type']=='MP4'){
$f = $mml_data['mml_mp4'];
}
$ex_p = explode('?',$f);
$path = "public_html/upload/music_mp3/".$ex_p[0];
$this->zip->read_file($path);
$d_type = 1;
}else{
$d_type = 0;
}
}
}
foreach($bal_data as $ba_row){
$dateA = $ba_row['bal_created'];
// your second date coming from a mysql database (date fields)
date_default_timezone_set('Asia/Kolkata');
$dateB = date("Y-m-d H:i:s");
$timediff = strtotime($dateB) - strtotime($dateA);
// if($timediff > 10800){ //echo 'more than 3 hours';
if($timediff > 86400){ //echo 'more than 24 hours';
$this->db->where('bal_mal_id',$ba_row['bal_mal_id'])
->set('bal_status','1')
->update('buy_album_list');
$d_type = 0;
}
else{
if($ba_row['bal_status']=='0'){
$mal_mml_data = $this->public_model->get_result_array_with_one_where('music_mp3_list','mml_mal_id',$ba_row['bal_mal_id']);
foreach($mal_mml_data as $re_row){
if($ba_row['bal_file_type']=='MP3'){
$f = $re_row['mml_mp3'];
}
if($ba_row['bal_file_type']=='MP4'){
$f = $re_row['mml_mp4'];
}
if($ba_row['bal_file_type']=='full_album'){
$f = $re_row['mml_mp3'];
}
$ex_p = explode('?',$f);
$path = "public_html/upload/music_mp3/".$ex_p[0];
$this->zip->read_file($path);
$d_type = 1;
}
}else{
$d_type = 0;
}
}
}
if($d_type=='1'){
ob_end_clean();
$zip_f_name = 'gravity_'.date('Y_m_d_His').'.zip';
$this->zip->download($zip_f_name);
}else{
$data['waring_msg'] = 'Sorry this file already downloaded.';
$this->load->view('paypal_status',$data);
}
}
還使用了函數ob_end_clean(); 從早期的問題,但問題仍然存在
主機提供商限制可以生成的文件的大小。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.