【发布时间】:2018-10-31 18:49:19
【问题描述】:
谁能修复我的代码
这是我的路线
Route::post('/ViewFile/{nama_file}', 'HSEController@getDownloadFile')->name('DownloadFile');
这是我的观点
<a href="{{ route('DownloadFile', $temuan->file) }}" target="_blank">File Lamp</a>
这是我的控制器
public function ViewFile($nama_file)
{
$file= public_path("/files/".$nama_file);
$headers = [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; '.$nama_file,
];
return response()->file($file, $headers);
}
我使用了该代码,结果是文件总是在下载,我想更改为在我的浏览器中打开,
【问题讨论】:
-
试试这个:
<a href="{{ route('DownloadFile', $temuan->file) }}" target="_blank">File Lamp</a>现在它会给你一个在新窗口中下载和打印的选项!! -
不,先生,仍然无法工作@HirenGohel
-
在您的控制器代码中也进行此更改:pastebin.com/QG2UDfTw
-
也不行@HirenGohel
-
这对我有用!也请参考这个答案:stackoverflow.com/questions/25938294/…
标签: laravel laravel-5 laravel-5.6