doudou201701 2014-04-09 13:47
浏览 19
已采纳

使用mimes:pdf调出方法[validatePdf]不存在

I am creating a package in my Laravel install and within my controller I have set up some rules. One of my rules is for a file upload to be a pdf.

I have...

$rules = array(
        'brochure'      => 'mimes|pdf'
    );

When I go to save my file, it says Method [validatePdf] does not exist. In another package I have an image rule saying...

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

This works and validates perfectly fine. How come one rule works and another doesn't? I've tried changing the mimes to jpg and it still couldn't find a validateJPG method either. Could this be because I'm working inside a package and it's trying to find it in there? If so, how would I go about changing this so it looks outside of my package for the method?

  • 写回答

1条回答 默认 最新

  • dqzve68846 2014-04-09 13:53
    关注

    By using a pipe to separatem them, you were telling Laravel you have a custom pdf validator, this is the way you tell it to use the pdf mime validator:

    $rules = array(
        'brochure'      => 'mimes:pdf'
    );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测