Answers for "laravel validate file type image"

PHP
0

laravel if file is image

$allowedMimeTypes = ['image/jpeg','image/gif','image/png'];
$contentType = $request->file->getClientMimeType();

if(! in_array($contentType, $allowedMimeTypes) ){
  return response()->json('error: Not an image');
}else{
  return $this->productService->storeImage($request->file);
}
Posted by: Guest on June-10-2021
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

Code answers related to "laravel validate file type image"

Browse Popular Code Answers by Language