Skip to content

Commit e2fb274

Browse files
nacholibrejaviereguiluz
authored andcommitted
Fix File Upload Example
1 parent 22a8d45 commit e2fb274

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

controller/upload_file.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,13 @@ You can use the following code to link to the PDF brochure of a product:
206206
use Symfony\Component\HttpFoundation\File\File;
207207
// ...
208208

209-
$product->setBrochureFilename(
210-
new File($brochuresDirectory.DIRECTORY_SEPARATOR.$product->getBrochureFilename())
211-
);
209+
if (!$form->isSubmitted() && $product->getBrochureFilename()) {
210+
$form->setData(['brochure' => new File($this->getParameter('brochures_directory').DIRECTORY_SEPARATOR.$product->getBrochureFilename())]);
211+
}
212+
213+
if ($form->isSubmitted() && $form->isValid()) {
214+
// ...
215+
}
212216

213217
Creating an Uploader Service
214218
----------------------------

0 commit comments

Comments
 (0)