I have a decoupled VueJS frontend and a Laravel API backend. When I upload a large file (3GB for instance) there's a Eloquent create() method that doesn't get executed. However, when I upload smaller files (a few hundred MB) it executes without problem.
My code:
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
]);
}
}
}
I log some text to see what executes and only the below logs are shown:
[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
What is causing this? My PHP server is configured to allow files of up to 5GB to be uploaded. I've also set my max_execution_time to 10mins to test and the problem persists. I've omitted the Vue code as I believe this is a backend issue.