Skip to content
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

as my previous PR #2454

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 5 additions & 3 deletions cookbook/doctrine/file_uploads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ look like this::
Next, create this property on your ``Document`` class and add some validation
rules::

use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\UploadedFile;

// ...

class Document
{
/**
Expand Down Expand Up @@ -322,7 +323,7 @@ object, which is what's returned after a ``file`` field is submitted::
$this->path = $this->getFile()->getClientOriginalName();

// clean up the file property as you won't need it anymore
$this->setFile(null);
$this->file = null;
}

Using Lifecycle Callbacks
Expand Down Expand Up @@ -408,7 +409,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
// the entity from being persisted to the database on error
$this->getFile()->move($this->getUploadRootDir(), $this->path);

$this->setFile(null);


// check if we have an old image
if (isset($this->temp)) {
Expand All @@ -417,6 +418,7 @@ Next, refactor the ``Document`` class to take advantage of these callbacks::
// clear the temp image path
$this->temp = null;
}
$this->file = null;
}

/**
Expand Down