How to delete image before update

In DW there used to be a way to delete an image (in an update form) before is was updated. Can this be done in Wappler too? If yes, how to go about this?

Sure in your server connect action - just before doing the database update step, add a step for the file connector to delete the old file.

If you like check this. I was creating a ‘delete image’ only when a new one was uploaded serveraction and took some notes for future reference.

Although it might confuse you a bit, it might also guide you. In this ‘semi-tutorial’ an image is deleted only if a new one is uploaded. It also checks if the image, that is about to be deleted, actually exists on the server.

It also creates a resized version of it and ‘on upload’ both ‘original’ & ‘resized’ images are deleted (in case they exist) and new ones are uploaded.

Of course at the end databse is also updated with the new image name, only in a new image is uploaded.

2 Likes

Wow nice tutorial Niko! You really should made a Wappler version of it.
You can post it in the Wappler docs github - or medium

Will attempt to get this working tomorrow, but it looks good, George approves, and it looks understandable even to me :grin:. Thanks

2 Likes

I managed to do it again (actually I did not). Followed @t11 How To to the letter. Image uploads, image resizes, but old image does not remove. I do not know if it has any influence on the outcome, but the Query options to get the old image in the how to (image number 5 @t11) differ from the query options I see in Wappler.20180823_getimage

Here he is again! I have tried following the tutorial by @t11 and almost nailed it. Now starting all over I run into problems again.
Single record update form with image upload. The image name will write to the database, but the file does not upload. Can anyone tell where I went wrong?
File upload behavior:

Update record behavior:

Maybe you can provide a link to your page, where we can check for errors during upload?

Here is the link http://dekontekstnederland.nl//content/home.php

Please check the output option for both update and file upload step.

Done that. Did not help. Reuploaded all “dmx” directories manually once more and now it all works fine.
Thanks for the assist

1 Like

The output options i requested were for debugging purposes only. Glad it works now.

Glad you made it work!

Not really working yet:
I have a update page with a form with texfields, textarea and file upload.
As action steps I have:

  • Database Connection
  • File upload
  • Load Image
  • Resize Image
  • Save Image
  • Database upload
    In that order. Now it will upload the new image, resize and save it. But it does not update the filename in the database and I still can’t delete the old image I am trying to replace