Reputation: 15
Only validation check if file upload. (file exist) if not upload file then need not check validation (In laravel validation)
Upvotes: 0
Views: 130
Reputation: 21
Be more specific and add some code if you want a better answer like @nakov wrote.
You can also cast a validation when you have a file uploaded with an if statement like this:
if ($request->hasfile('photo')) {
$request->validate(['photo' => 'image|mimes:jpeg,bmp,png'])
}
Upvotes: 0
Reputation: 14268
You should share some code so you get a better help. But you can use the nullable
rule in order to allow empty data like this:
// as an example
$request->validate([
'photo' => 'nullable|mimes:jpeg,bmp,png'
]);
Upvotes: 1