I have a VueJs form that uploads files. Validation is being handled by the Laravel back-end. The problem I have is that the Illuminate\Http\UploadedFile is not being removed from the request object for subsequent requests, and as such the validation for files is not working.
I have tried to reset the request parameters with $request->replace([]) after a successful upload, but on subsequent uploads (when no file has been selected) the file remains in the request object.
Successful upload:
[2019-07-23 11:01:06] local.DEBUG: array (
'name' => 'a',
'description' => 'a',
'resourceType' => 'sample',
'applicationTypes' =>
array (
0 => '1',
),
'authorities' =>
array (
0 => '1',
),
'file' =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => false,
'originalName' => 'blueprint.pdf',
'mimeType' => 'application/pdf',
'error' => 0,
'hashName' => NULL,
)),
)
Subsequent uploads when no file has been selected
[2019-07-23 11:01:24] local.DEBUG: array (
'name' => 'b',
'description' => 'b',
'resourceType' => 'sample',
'applicationTypes' =>
array (
0 => '1',
),
'authorities' =>
array (
0 => '1',
),
'file' =>
Illuminate\Http\UploadedFile::__set_state(array(
'test' => false,
'originalName' => 'blueprint.pdf',
'mimeType' => 'application/pdf',
'error' => 0,
'hashName' => NULL,
)),
)
Does anyone know what's causing the file to remain in the request?