0
最初は、ファイル名にアラビア文字を読み込まないので、ダウンロードすると.pdfしか表示されないため、アラビア文字をpreg_replaceに追加してファイル名を取得しました。今、ファイル名は私のコードに何か問題が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;
}
'preg_replace'を' mb_ereg_replace'に置き換えると、これで問題は解決しますか?または、さらなるステップが必要ですか? –
私はそれが問題を解決すべきだと考えます。 – Sarmad