【发布时间】:2017-10-21 23:05:37
【问题描述】:
我在storage/app/ 目录中有一个目录dl,我设法使用Storage::get(dl/filename.ext) 获取文件内容
但现在我想为这些文件创建一个下载链接,但我对 Response 和 Storage 外观如何工作感到有些困惑。
我正在使用带有这样定义路由的 Response 外观:
Route::get('site/download/{fileName}', function($fileName) {
$path = storage_path().'/app/dl/'.$fileName;
return Response::download($path, $fileName);
});
注意:我使用的是 Laragon,站点是根目录。
发生的问题是 Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?) 。我知道这是一个已知问题,但在寻找解决方案后,我没有找到适合我需要的东西。这些文件是 C 文件,mime 类型可能应该是“文本/纯文本”,但我不知道如何以及在哪里指定它。
我还寻找其他解决方案,但file does not exists 不断出现。
我需要一些东西来从storage/app/dl/ 下载文件。
【问题讨论】: