Symfony Delete image uploaded with filesystem

i would like to delete an image from my / uploads folder with fileSystem but I can’t do it. Here is my code.
Thank you so much !

 * Permet de supprimer des images
 * @Route("/delete/image/{id}", name="image_delete", methods={"DELETE"})
 * @param Image $image
 * @param EntityManagerInterface $manager
 * @return Response
public function deleteImage(Image $image, EntityManagerInterface $manager)
     * Je gère la suppression du dossier "uploads" ou l'image est stockée
    //Je récupère le nom de l'image
    $filename = $image->getName();
    // Je crée une instance de kla classe fileSystem
    $fileSystem = new Filesystem();
    //Je supprime l'image du dossier

     * Je gère la suppression en bdd
    return new Response('deleted', Response::HTTP_OK);


Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *