mercredi 24 août 2016

Laravel validation mimetype check, ok on windows, bug on linux

I'm using the following code in laravel to check for a text file on upload:

    $validator = Validator::make($input, [
        'list' => 'required|mimetypes:text/plain|max:5000',
        'group_id' => 'required|exists:groups,id',
    ]);

    if($validator->fails()) {
        return redirect()->back()->withErrors($validator);
    }

On windows (local machine) runs fine, on Linux (host) I get the validation error for the mimetype:

Oops! Something went wrong!
validation.mimetypes

I dumped the file upload on both platforms, both returned on the UploadedFile object:

  -mimeType: "text/plain"
  -size: 259286
  -error: 0

Uploaded file is text, and it's the same on every platform. I also tried variatons on laravel validation, such as: mimes:txt,csv, didn't work.

Really frustrating, can anyone help out?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire