davy_yg's avatar
Level 27

validation

Hello,

How to validate an upload file that the type must be a pdf file or an image file ?

ref: https://laravel.com/docs/8.x/validation

JadwalController.php

		 $this->validate($request, [               
           		'bukti' => 'required|image'        
       ]);

I don't know how to validate the pdf file.

0 likes
1 reply
tykus's avatar
tykus
Best Answer
Level 104

Use the mimes/mimetypes rule, e.g.

$this->validate($request, [
    'bukti' => ['required', 'mimes:jpeg,bmp,png,gif,svg,pdf'],
]);

Please or to participate in this conversation.