【问题标题】:Zip is not downloading in CodeIgniterZip 未在 CodeIgniter 中下载
【发布时间】:2023-03-24 04:13:01
【问题描述】:

我使用jQuery将一些数据发布到页面并使用CodeIgniter中的zip库下载zip文件,它只输出一些字符串数据并且下载不起作用。

代码:

$data = json_decode($data);
foreach ($data as $id) {
    $this->db->where('idjobs', $id);
    $this->db->where('jobs_has_clients.jobs_idjobs', $id);
    $this->db->join('status', 'status.idstatus = jobs.status_idstatus', 'left');
    $this->db->join('jobs_has_clients', 'jobs_has_clients.jobs_has_clientsSet = status.statusFor', 'left');
    $this->db->join('cv', 'cv.clients_idclients = jobs_has_clients.clients_idclients', 'left');
    $get_all_data_q = $this->db->get('jobs');
    $all_data_to_array_q = $get_all_data_q->result_array();
    $a = 0;
    foreach ($all_data_to_array_q as $zipData) {
        $path = './' . $zipData['cvFilePath'];
        $this->zip->read_file($path);
        $a++;
    }

    if ($a != 0) {
        $this->zip->download('job_' . $id . '_' . date('Y-m-d') . '_cv_archive.zip');
    }
}

【问题讨论】:

  • 你的代码呢?我们怎么能不看你在做什么就知道出了什么问题。
  • @Alex 对不起先生。我只是添加代码。
  • 您是否尝试通过 jquery 下载?不要相信你能做到。
  • 您可能看到的是原始 zip 流,因为它无法以这种方式下载(可能是错误的)。
  • 您应该从浏览器加载脚本,而不是从 jQuery。

标签: php ajax codeigniter zip


【解决方案1】:

您无法从 Ajax 查询启动下载。您应该从浏览器加载脚本,而不是从 jQuery。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-12
    • 2019-06-10
    • 2016-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多