阅读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行中转换为布尔值
答案 0 :(得分:2)