Skip to content
Open
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: 7 additions & 3 deletions controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,13 @@ You can use the following code to link to the PDF brochure of a product:
use Symfony\Component\HttpFoundation\File\File;
// ...

$product->setBrochureFilename(
new File($this->getParameter('brochures_directory').'/'.$product->getBrochureFilename())
);
if (!$form->isSubmitted() && $product->getBrochureFilename()) {
$form->setData(['brochure' => new File($this->getParameter('brochures_directory').'/'.$product->getBrochureFilename())]);
}

if ($form->isSubmitted() && $form->isValid()) {
// ...
}

Creating an Uploader Service
----------------------------
Expand Down