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 @@ -335,6 +335,7 @@ automatically upload the file when persisting the entity::
335
335
namespace App\EventListener;
336
336
337
337
use Symfony\Component\HttpFoundation\File\UploadedFile;
338
+ use Symfony\Component\HttpFoundation\File\File;
338
339
use Doctrine\ORM\Event\LifecycleEventArgs;
339
340
use Doctrine\ORM\Event\PreUpdateEventArgs;
340
341
use App\Entity\Product;
@@ -376,6 +377,10 @@ automatically upload the file when persisting the entity::
376
377
if ($file instanceof UploadedFile) {
377
378
$fileName = $this->uploader->upload($file);
378
379
$entity->setBrochure($fileName);
380
+ } elseif ($file instanceof File) {
381
+ // prevents the full file path being saved on updates
382
+ // as the path is set on the postLoad listener
383
+ $entity->setBrochure($file->getFilename());
379
384
}
380
385
}
381
386
}
You can’t perform that action at this time.
0 commit comments