File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,7 @@ automatically upload the file when persisting the entity::
310310 namespace AppBundle\EventListener;
311311
312312 use Symfony\Component\HttpFoundation\File\UploadedFile;
313+ use Symfony\Component\HttpFoundation\File\File;
313314 use Doctrine\ORM\Event\LifecycleEventArgs;
314315 use Doctrine\ORM\Event\PreUpdateEventArgs;
315316 use AppBundle\Entity\Product;
@@ -351,6 +352,10 @@ automatically upload the file when persisting the entity::
351352 if ($file instanceof UploadedFile) {
352353 $fileName = $this->uploader->upload($file);
353354 $entity->setBrochure($fileName);
355+ } elseif ($file instanceof File) {
356+ // prevents the full file path being saved on updates
357+ // as the path is set on the postLoad listener
358+ $entity->setBrochure($file->getFilename());
354359 }
355360 }
356361 }
You can’t perform that action at this time.
0 commit comments