Answers for "validate image upload laravel"

PHP
1

image validate in laravel validater

$this->validate($request, ['file' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',]);
Posted by: Guest on October-20-2020
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

Browse Popular Code Answers by Language