Reputation: 1220
I have a little problem with one request file in my Store controller !
I get the orginal file name extension like this :
$licencie_amateur->cert_medical_surclassement = $request->file('cert_medical_surclassement')->getClientOriginalName();
Sometimes the user don't need to put a file "cert_medical_surclassement" i would like to do a condition like : If the file was added ok but if there is no files in the field i pass to the other variable .
Someone know how i could do this ? thanks a lot in advance
Upvotes: 0
Views: 303
Reputation: 7992
Use the hasFile()
method
if ($request->hasFile('cert_medical_surclassement')) {
$licencie_amateur->cert_medical_surclassement = $request->file('cert_medical_surclassement')->getClientOriginalName();
} else {
// else code
}
More info: Documentation
Upvotes: 2