Laravel If File Is Image

[Solved] Laravel If File Is Image | Php - Code Explorer | yomemimo.com
Question : laravel if file is image

Answered by : fahim-foysal-rabby

$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);
}

Source : | Last Update : Thu, 17 Jun 21

Answers related to laravel if file is image

Code Explorer Popular Question For Php