//这里是下载zip文件 header("Content-Type: application/zip"); header("Content-type: application/octet-stream"); header("Content-Transfer-Encoding: Binary"); header("Content-Length: " . filesize($file_path)); $ua = $_SERVER [ 'HTTP_USER_AGENT' ]; $file_name = basename($file_path); $encoded_filename = urlencode($file_name); $encoded_filename = str_replace("+", "%20", $encoded_filename); if (preg_match("/Chrome/", $ua)) { header('Content-disposition: attachment; filename=' . $file_name); }else if (preg_match("/Firefox/", $ua)) { header("Content-Disposition: attachment; filename=\"" . $file_name."\"");//火狐要用双引号 } else{ header('Content-Disposition: attachment; filename="' . rawurlencode($file_name) . '"'); } header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件 header('Content-Length: ' . filesize($file_path)); @readfile($file_path);
php 程序实现文件下载,兼容IE、Firefox、Chrome等浏览器
最新推荐文章于 2022-02-25 14:33:59 发布