vendredi 18 juin 2021

Laravel 8 File Validation

I'm new to laravel and I have been struggling to validate uploaded files.

Below is the code that handles validation:

// (I tried mime, mimes, mimetypes) none of them are validating any of the files correctly.
        $validator = Validator::make($request->all(), [
            'proposal_summary' => 'mimetypes:application/pdf|max:2048',
            'plagiarism_report' => 'mimetypes:pdf,doc,docx,txt|max:2048',
            'final_proposal' => 'mimes:pdf,doc,docx,txt|max:2048',
        ]);

I tested this with PDF, docx and txt files, all without success. I get an error saying the files must be a file of type: pdf, doc, docx, txt. Even though they are. I am sure I am doing something wrong, so any help would be appreciated. Please let me know if you require more code or further explanation.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire