【发布时间】:2018-04-05 12:49:51
【问题描述】:
所以我正在测试我刚刚部署到带有 Nginx 的 Ubuntu 服务器的 Laravel 应用程序是否正常工作,并且我需要下载一些使用 Angular 从前端上传的文件。
我可以毫无问题地上传文件,并且我确保这些文件实际上在服务器中,是的,它们按预期保存。
但是当我需要下载它们时,我收到错误:“无法创建文件”
它在我的本地机器上运行,所以我猜这是一种配置问题,但我不确定要更改什么。
该文件是通过带有 Http 的 GET 请求请求的,其标题为:{ responseType: ResponseContentType.Blob },后者是 Angular 的一部分。
在 Laravel 中,这就是我返回文件的方式:
public function download($activityId) {
$activity = $activity = Activity::find($activityId, ['student_id', 'file_storage']);
$file = public_path() . '/storage/activityFiles/' . $activity['student_id'] . '/' . $activity['file_storage'];
return response()->download($file);
}
我会错过什么?
【问题讨论】: