laravel if file is image

Solutions on MaxInterview for laravel if file is image by the best coders in the world

showing results for - "laravel if file is image"
Elisa
05 Apr 2017
1$allowedMimeTypes = ['image/jpeg','image/gif','image/png'];
2$contentType = $request->file->getClientMimeType();
3
4if(! in_array($contentType, $allowedMimeTypes) ){
5  return response()->json('error: Not an image');
6}else{
7  return $this->productService->storeImage($request->file);
8}