Delete File Problems

Hi, in my new File Upload form I am gradually filing out all the expected functionality. With help from this forum I recently got the file downloads working perfectly. All the Routing and File Security issues are resolved. I thought I would be able to easily take the FileDownload procedure and substitute FileRemove to get a File Delete procedure. Turns out not so.

I have diligently copied, from the FileDownload procedure, the Routing, Anchor button on the App and the API. Using the new Anchor button, the download worked proving that the new copied items are good.

Then, in the API I disabled the FIleDownload and added a FileRemove. I set the filepath to be exactly the same as the FileDownload.

But when I click the new Anchor button, the underlying file gets deleted but the page disappears and only the SetValue message from the API is displayed.

image

If I disable the FileRemove and enable the FileDownload, everything works well again.

So the question is , what is the difference between FileDownload and FileRemove that I am not spotting?

Hi. That is actually the wrong question.
The issue here is the anchor tag.
Anchor is supposed to redirect you, generally speaking.

The way Wappler’s file download works - it needs the server action to be opened on page, and not via ajax - which is why you use anchor tag, instead of a server connect to call the download server action.

Now, when you want to run the remove server action - that is just a regular server action which needs to be called via ajax - so use a server connect. On click of anchor tag, you can set it to load the server connect. Or, you can use a button (which is more appropriate), and set the same thing on click of the button.

Hi Sid

That was most helpful. All working now.

Thank you.

1 Like