//這裏是下載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等瀏覽器
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.