📜  laravel 如果文件是图像 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:15.347000             🧑  作者: Mango

代码示例1
$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);
}