Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
}
 
PREVIOUS NEXT
Tagged: #laravel #file #image
ADD COMMENT
Topic
Name
6+4 =