Use uniqid() instead of random_bytes()

This commit is contained in:
Jannis Portmann 2021-06-15 15:56:42 +02:00
parent 633da5406b
commit 91fb30ed40

View file

@ -50,7 +50,7 @@ class OfferController extends AbstractController
$offer->setCreatedAt(new \DateTime()); $offer->setCreatedAt(new \DateTime());
if ($photo = $form['photo']->getData()) { if ($photo = $form['photo']->getData()) {
$filename = bin2hex(random_bytes(6)).'.'.$photo->guessExtension(); $filename = uniqid().'.'.$photo->guessExtension();
try { try {
$photo->move($photoDir, $filename); $photo->move($photoDir, $filename);
} catch (FileException $e) { } catch (FileException $e) {
@ -103,7 +103,7 @@ class OfferController extends AbstractController
public function editOffer(Offering $offer, OfferingRepository $offerRepository, Request $request, string $photoDir): Response public function editOffer(Offering $offer, OfferingRepository $offerRepository, Request $request, string $photoDir): Response
{ {
$form = $this->createForm(OfferingFormType::class, $offer); $form = $this->createForm(OfferingFormType::class, $offer);
$user = $this->getUser(); $user = $this->getUser();
if ($offer->getByUser() === $user) if ($offer->getByUser() === $user)
{ {
$form->handleRequest($request); $form->handleRequest($request);
@ -113,7 +113,7 @@ class OfferController extends AbstractController
$offer->setCreatedAt(new \DateTime()); $offer->setCreatedAt(new \DateTime());
if ($photo = $form['photo']->getData()) { if ($photo = $form['photo']->getData()) {
$filename = bin2hex(random_bytes(6)).'.'.$photo->guessExtension(); $filename = uniqid(random_bytes(6)).'.'.$photo->guessExtension();
try { try {
$photo->move($photoDir, $filename); $photo->move($photoDir, $filename);
} catch (FileException $e) { } catch (FileException $e) {