Deleting record and associated image file

I have a list with sponsors. Each sponsor has a logo img_file which is saved in folder uploadlogo. Now I want to delete the sponsor (no problem), but I also want to delete the logo from the uploadlogo_folder. And there I do have a problem. Any directions would be highly appreciated.


1.Just run a query getting user’s logo filename from the database.
2.Use query from step (1) as an expression into a ‘repeat’ action
3. Output logo filename inside the repeat created in step 2
Now inside the repeat
4. Check if file exists using the pathToFile/{{filenameFromTheRepeat}}
5. If yes add a ‘delete file action’ using again the pathToFile/{{filenameFromTheRepeat}}
Now outside from the repeat
6. Delete user’s record from the database.

Hope it helps
Thank you!


Sorry to say, but not working. Now on pageload the first record will be deleted (which it shouldn’t), but the image is not. I would vote for an easier way (for me at least) to delete files/images, since I haven’t been able to get it done in the past six months.

please send a screenshot of what you have placed inside the ‘if file exists’

Thank you

please try removing the ‘…/’ just place ‘uploadlogo/{{logo}}

Thank you

Also if the wrong record is deleted this has to do with the value that is passed as filter in the delete server action. So maybe the image is not deleted for the same reason.

The path to the folder must be generated by the UI, so i do not recommend changing that manually - it can break the whole server action.

1 Like

Yes true if it was created by the UI then it should not be changed, just in case it was manually added

1 Like

I am not sure how could this be easier - you get the record, repeat it and point to the file to be deleted. It just follows the logic. That's good with server connect as you don't need to know how to do something exactly - you can build it following the logic.

Yes I agree, just follow the logic steps and it is a matter of more or less 20mins to complete it. Please just check if the right record is selected when running the queries.

The record itself is correctly deletede. Just not the image (yet). I tried …/uploadlogo/{{logo}}, uploadlogo/{{logo}}, only {{logo}}. No joy

You can debug this enabling output info option and see what the output in browser console is. The error there will show what have you done wrong.

I see the error. Seems it can’t find the recordId, but the number shown is correct. Will work on it again next week.

if the record is correctly deleted, then the recordID must be there. Have a look under Globals and see what is listed there. This should match up with what you have in the delete action as per

Under Globals you should see something like


where imageID is used to target the database entry
imageGalleryID is used to target the folder where the image resides
imageFile is the name of the file

The File Path for the File Remove action (in my case) looks like


In your case it should probably look like


If that is my correct interpretation, then make sure that logo shows under Globals and that it gets the proper feed from the form input.

1 Like

Check this tutorial too

1 Like

Excellent video, short and easy to follow.

The only thing that I do differently (I am not saying that this is correct), I do not wrap the details in the data-details element. I usually leave the data-details element at the bottom of my document. This works just as well. I find that this allows me to place the details anywhere on my page without being restricted.

B.t.w., I am in love with the voice, where did you get this?

Thank you for your feedback. Regarding ‘’ wrapping, I am doing it like this because sometimes (from the DW era) it was not always working when was leaving it (the dmx-detail) at the bottom and wanted to pass values in a modal. This is why I am following this strategy since it always worked for me. But yes truth is that it should also be working leaving it at the botttom

Thank you!
PS the voice is rigth from this service