laravel - 为什么图像验证接受文本文件 laravel postman?
问题描述
我正在使用 laravel 8,我正在从邮递员上传文件。我还为 png、jpeg 和 jpg 编写了验证规则。但是当我选择任何其他文件时,它也会上传它。邮递员中的表单数据在 此处输入图像描述
我的验证资源文件是
public function rules()
{
return [
'invoice_id' => ['required', 'string'],
'invoice_date' => ['required', 'date'],
'invoice_photo_url' => ['required','image','mimes:jpeg,png,jpg'],
'invoice_net_total' => ['required','regex:/^\d*(\.\d{1,2})?$/'],
];
}
我的控制器方法是
public function upload(InvoiceUploadRequest $request)
{
try {
return $this->responseWithSuccess(true,"Invoice successfully uploaded!",
$this->invoiceInterface->uploadInvoice($request), Response::HTTP_OK);
}catch (\Exception $exception){
return $this->responseWithError($exception->getMessage(), Response::HTTP_OK);
}
}
怎么能解决这个问题。谢谢
解决方案
推荐阅读
- sql-server - 多个 on 语句如何在单个内部联接中工作?
- python - 抑制 xarray.DataArray.plot 中的标签
- javascript - 将对象数组重新格式化为键数组
- sql - 没有函数,没有Split_String。使用 XML 通过分隔符将字符串拆分为不同的字段
- python - 将列表转换为 NumPy 数组的问题
- c# - Newtonsoft.Json 序列化双重格式化为字符串
- text - H1标签上的文本后面的行
- html - 使用 Sibling Combinator 为动态内容创建选项卡
- java - 在 onOptionsItemSelected 中选择第二个项目会导致应用程序崩溃
- html - 为什么我的 XSL 将兄弟姐妹作为空元素的子元素输出?