Selaa lähdekoodia

[Backend] Fix bug duplicate image

develop
Fab 3 vuotta sitten
vanhempi
commit
1395b8111e
1 muutettua tiedostoa jossa 3 lisäystä ja 1 poistoa
  1. +3
    -1
      ShopBundle/Services/UtilsProcess.php

+ 3
- 1
ShopBundle/Services/UtilsProcess.php Näytä tiedosto

@@ -93,13 +93,15 @@ class UtilsProcess


if ($entity->getImage() && file_exists($basePath . $entity->getImage())) {
$extension = (pathinfo($basePath . $entity->getImage(), PATHINFO_EXTENSION));
$extension = pathinfo($basePath . $entity->getImage(), PATHINFO_EXTENSION);

if ($extension == "jpg" || $extension == "png" || $extension == "gif") {
$newImage = md5(uniqid()) . '.' . $extension;
if ($folder) $newImage = $folder . '/' . $newImage;
copy($basePath . $entity->getImage(), $basePath . $newImage);
$entity->setImage($newImage);
}else{
$entity->setImage(null);
}
} else {
$entity->setImage(null);

Loading…
Peruuta
Tallenna