Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mbo's avatar
Level 3

Image upload e

I'm setting up an website where users should be able to upload multi photos. They must also be able to delete the photos when editing their profile.

Any advice how to setup? Being so user friendly and stable as possible.

Thanks in advance.

0 likes
4 replies
mbo's avatar
Level 3

Himanshurajvanshi,

thanks for your reaction. I looks like a good way to do so.

Do you have some suggestions for delete the images?

currently i'm using this libary. https://www.dropzonejs.com/ But is not as stable as i want. Especially when the form does not pass the validation.

Thanks for the reaction.

himanshurajvanshi's avatar
Level 3

@mbo

if($request->ajax()) { 
        $photo = Photo::find($request->photoId); //Get image by id or desired parameters

        if(File::exists($destinationPath.$photo->file_name)) //Check if file exists
            File::delete($destinationPath.$photo->file_name) //Delete file from storage

        $photo->delete()   //Delete file record from DB

        return response('Photo deleted', 200); //return success
    }

delete image like this or if user have those image path then remove those path from imahe column where you assign to image to user table.

mbo's avatar
Level 3

Thanks for the help. I was thinking of something else but this will help. have a nice day!

Please or to participate in this conversation.