0
首先,它是沒有的preg_replace讀阿拉伯語字符的文件名,所以當下載它顯示.PDF只讓我增加了阿拉伯語字符preg_replace函數來獲取文件名是。現在,文件名顯示爲「اÙÙÙاعداÙعربية.PDF」的preg_replace和的file_get_contents不讀阿拉伯語文件名
我不知道如果有什麼錯我的代碼
public function download($id){
$toReturn = study_material::where('id',$id)->first();
if(file_exists('uploads/material/'.$toReturn->material_file)){
$fileName = preg_replace('/[^أ-يa-zA-Z0-9-_\.]/','',$toReturn->material_title). "." .pathinfo($toReturn->material_file, PATHINFO_EXTENSION);
header("Content-Type: application/force-download");
header('Content-Type: text/html; charset=utf-8');
header("Content-Disposition: attachment; filename=" . $fileName);
echo file_get_contents('uploads/material/'.$toReturn->material_file);
}
exit;
}
所以你的意思是我用'mb_ereg_replace'替換'preg_replace'這會解決這個問題嗎?或需要進一步的步驟? –
我相信它應該解決這個問題。 – Sarmad