Skip to content

Fix php warning when no file was uploaded #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cookbook/doctrine/file_uploads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ object, which is what's returned after a ``file`` field is submitted::
public function upload()
{
// the file property can be empty if the field is not required
if (!$this->file) {
if (empty($this->file)) {
return;
}

Expand Down Expand Up @@ -245,7 +245,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
*/
public function preUpload()
{
if ($this->file) {
if (!empty($this->file)) {
// do whatever you want to generate a unique name
$this->setPath(uniq().'.'.$this->file->guessExtension());
}
Expand All @@ -256,7 +256,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
*/
public function upload()
{
if (!$this->file) {
if (empty($this->file)) {
return;
}

Expand Down Expand Up @@ -303,7 +303,7 @@ property, instead of the actual filename::
*/
public function preUpload()
{
if ($this->file) {
if (!empty($this->file)) {
$this->setPath($this->file->guessExtension());
}
}
Expand All @@ -313,7 +313,7 @@ property, instead of the actual filename::
*/
public function upload()
{
if (!$this->file) {
if (empty($this->file)) {
return;
}

Expand Down