我有一个解耦的VueJS前端和一个Laravel API后端。 当我上传一个大文件(例如3GB)时,有一个Eloquent create()方法无法执行。但是,当我上传较小的文件(几百MB)时,它的执行没有问题。
我的代码:
public function store(Request $request){
if(count($request->file('files'))){
$shareId = substr(md5(rand()), 0, 7);
try{
$user = User::where('name', 'Anon')->first(); //save file anonymously
$upload = $user->uploads()->create(['share_id' => $shareId, 'visibility' => 'public']);
foreach($request->file('files') as $file){
\Log::info('before file store');
$disk = Storage::disk('files');
$disk->put($file->getClientOriginalName(), fopen($file, 'r+'));
\Log::info('after file
\Log::info('before db create');
//the below code and everything after it doesn't execute
$upload->files()->create(['name' => 'testname',
'originalName' => $file->getClientOriginalName(),
'size' => $file->getClientSize(),
'path' => 'test', 'visibility' => 'public',
'type' => $file->getClientOriginalExtension()]);
\Log::info('after db create');
}
return response()->json([
"success" => $shareId
]);
}
catch(\Exception $e){
return response()->json([
"error" => $e
]);
}
}
}
我记录一些文本以查看执行的内容,并且仅显示以下日志:
[2019-09-27 14:15:52] local.INFO: before file store
[2019-09-27 14:15:52] local.INFO: after file store
[2019-09-27 14:15:52] local.INFO: before db create
是什么原因造成的?我的PHP服务器配置为允许上传最大5GB的文件。我还将max_execution_time设置为10分钟以进行测试,问题仍然存在。我已经省略了Vue代码,因为我认为这是一个后端问题。