我正在制作一个表单来编辑用户可以上传文件的实体。当他进行一些编辑时,我想检查他是否上传了另一个文件,以了解我是否必须删除另一个文件。我找不到如何知道输入文件是否为空。我怎样才能做到这一点?
问问题
2944 次
1 回答
0
public function upload()
{
if (null === $this->file) {
// this is the condition where you can get to know that the value of
// input field is null or not
}
// if there is an error when moving the file, an exception will
// be automatically thrown by move(). This will properly prevent
// the entity from being persisted to the database on error
$this->file->move($this->getUploadRootDir(), $this->path);
unset($this->file);
}
于 2012-05-10T12:49:10.250 回答