ユーザーがファイルをアップロードできるエンティティを編集するフォームを作成しています。彼がいくつかの編集を行うとき、彼が別のファイルをアップロードしたかどうかを確認して、他のファイルを削除する必要があるかどうかを知りたい. 入力ファイルが空かどうかを知る方法が見つかりません。これどうやってするの?
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);
}
symfony のドキュメントを確認してください
于 2012-05-10T12:49:10.250 に答える