背景我有一個在 CentOS 服務器上運行的 PHP 應用程序。前端使用 ajax 調用來訪問 PHP 腳本。該腳本從服務器返回一個文件并將其下載到客戶端。問題如果文件#名中有 ,則文件下載失敗。例子File#Name.pdf = 無法正確下載FileName.pdf = 是否正確下載這是用于檢索文件的 PHP,if( isset($_GET['path'])) { $path = $_GET['path']; if(!file_exists($path)) { die('file not found'); } else { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.$path); header('Content-Length: '.filesize($path)); readfile($path); ob_clean(); flush(); exit; }}問題為什么在名稱中時文件無法下載#?
- 1 回答
- 0 關注
- 276 瀏覽
添加回答
舉報
0/150
提交
取消