File tree 1 file changed +5
-0
lines changed
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::
310
310
namespace AppBundle\EventListener;
311
311
312
312
use Symfony\Component\HttpFoundation\File\UploadedFile;
313
+ use Symfony\Component\HttpFoundation\File\File;
313
314
use Doctrine\ORM\Event\LifecycleEventArgs;
314
315
use Doctrine\ORM\Event\PreUpdateEventArgs;
315
316
use AppBundle\Entity\Product;
@@ -351,6 +352,10 @@ automatically upload the file when persisting the entity::
351
352
if ($file instanceof UploadedFile) {
352
353
$fileName = $this->uploader->upload($file);
353
354
$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());
354
359
}
355
360
}
356
361
}
You can’t perform that action at this time.
0 commit comments