Answers for "if user image upload then only laravel validator should check image format"

PHP
1

laravel validation image or file

$validate = Validator::make($params = $request->all(), [
  'type' => 'required',
  'files' => 'mimes:jpeg,png,jpg,svg,doc,docx,odt,pdf,tex,txt,wpd,tiff,tif,csv,psd,key,odp,pps,ppt,pptx,ods,xls,xlsm,xlsx'
]);
Posted by: Guest on May-11-2021
0

laravel upload image document validator

$document = $request->upload_file;
if ($document) {
  $validate = Validator::make(
    [
      'extension' => strtolower($request->upload_file->getClientOriginalExtension()),
    ],
    [
      'extension' => 'in:jpg,jpeg,png,gif,pdf,csv,docx,xlsx,txt',
    ]
  );
  if ($validate->fails())
    return redirect()->back()->withErrors($validator->errors());

  $fileName = $document->getClientOriginalName();
  $document->move('public/documents', $fileName);
  $data['upload_file'] = $fileName;
}
Posted by: Guest on June-24-2021

Code answers related to "if user image upload then only laravel validator should check image format"

Browse Popular Code Answers by Language