【问题标题】:Symfony 2 File Upload. How to throw exception on move()Symfony 2 文件上传。如何在 move() 上抛出异常
【发布时间】:2023-03-25 02:17:02
【问题描述】:

阅读 symfony 文档,http://symfony.com/doc/current/cookbook/doctrine/file_uploads.html

// you must throw an exception here if the file cannot be moved
// so that the entity is not persisted to the database
// which the UploadedFile move() method does automatically
$this->file->move($this->getUploadRootDir(), $this->path);

如果我这样做了

if ($this->file->move(...)) 

我遇到了一个错误

可捕获的致命错误:类 Symfony\Component\HttpFoundation\File\File 的对象无法在 .../xxx.php 第 96 行中转换为布尔值

【问题讨论】:

    标签: file-upload symfony


    【解决方案1】:

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-27
    • 2014-03-04
    • 2021-12-01
    • 1970-01-01
    相关资源
    最近更新 更多