【问题标题】:Laravel not uploading svg image even though it is in allowed typesLaravel 不上传 svg 图像,即使它是允许的类型
【发布时间】:2019-06-28 04:16:51
【问题描述】:

我正在尝试从 laravel 上传 svg,但出现此错误。

The icon must be a file of type: png, svg, gif, jpeg.

这是验证器的代码。

$rules = array(
    'image' => 'mimes:png,gif,svg,jpeg|max:10000' // max 10000kb
);

【问题讨论】:

  • 你试过了吗:mimes:jpeg,png,jpg,gif,svg?
  • 是的,尝试了同样的错误。
  • 您需要养成accepting answers 的习惯,它可以帮助您解决问题。您将获得积分,并鼓励其他人帮助您。

标签: laravel image file-upload


【解决方案1】:

你可以使用

$rules = array( 'image' => 'image' );

它支持 jpeg、png、bmp、gif 或 svg 文件类型。

查看此处了解更多信息。 https://laravel.com/docs/5.4/validation#rule-image

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 2018-10-13
    相关资源
    最近更新 更多