0

Only validation check if file upload. (file exist) if not upload file then need not check validation (In laravel validation)

2 Answers 2

1

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'
]);
Sign up to request clarification or add additional context in comments.

Comments

0

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'])
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.