2011-12-08 122 views
1

閱讀symfony的文檔,http://symfony.com/doc/current/cookbook/doctrine/file_uploads.htmlSymfony 2文件上傳。如何在移動拋出異常()

// 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(...)) 

Catchable Fatal Error: Object of class Symfony\Component\HttpFoundation\File\File could not be converted to boolean in .../xxx.php line 96

回答