Delete a File

Is there anyway to delete a text file on a server?

I tried DeleteFile but that is not supported.


Can you explain what you are trying to do?

Generally, client applications don't have access to directly delete files on remote servers. And if that were to be an option in a particular implementation, it is going to involve communicating with the server in a way that is specific to that particular server? So what kind of server are you using and how are you connecting to it to make such a request?

Hi Andrew,

We have a regular web server that is hosted at siteground. We have a phone app that uses ftp
to send small text file to the server. We then have a webpage on that server that can read these files and process them. We need to delete them once processed.

I believe this can be done by calling a PHP script, but we would like to do everything
using TMS Web core if possible.


Hmm. I'm still not clear on what is running where.

When you run a TMS WEB Core app, the app is delivered by a server to a client device, so the TMS WEB Core code that you write is running on the client, not on the server. If there is a PHP script that runs on the server that can be called to delete the file, then the TMS WEB Core app can call that script if it is accessible in some way. Usually they aren't though.

I can try and explain better, but I'll need you to fill in the blanks.

  1. You've got a Phone app that uploads a data file to a server.
  2. The server stores that file somewhere that can be seen by your TMS WEB Core app.
  3. From another computer somewhere, you start your TMS WEB Core app.
  4. Your TMS WEB Core app requests this data from the server and processes it.
  5. The TMS WEB Core app files might be hosted on the same server?
  6. But the app isn't running on the server - it is running on another computer?
  7. So in order for it to delete the data, it has to send a request to the server to do so.
  8. This is similar to the request it has to send to the server to get the data?
  9. The server can then accept that request and launch the php script to delete the data.
  10. OR the server has a command that can be called directly by the TMS WEB Core app?

Eeither way, the TMS WEB Core app isn't (normally?) running direclty on the server, so it has to ask the server to delete the file in some way. Sometimes a PHP script can be accessed directly, with various security mechanisms to ensure that it isn't accessed improperly, but that's still not uncommon.

If you're sending the file via FTP, maybe you can use FTP to delete it as well?

Hi Andrew,

Yes, it is a TMS Web application. It is just a regular web page. The files I need to delete are on the same server as the TMS Web Application. They are in the same folder. This is all done using a web browser.


Right, but when your TMS Web application is actually running, it is running in the browser, not on the server. So even though 100% of the files might be there, it is the browser that loads them and is what is running the application. So when TMS WEB Core wants to access files, it only has access to whatever the browser has access to.

Tell me more about this PHP script? It might be easy enough for the browser to call it by adding a bit of code to the TMS WEB Core application.

For example, on the server, if there is a PHP script called "delete_processed_file.php" then perhaps the TMS WEB Core app can just call something like "" or something along those lines.

The permissions and location for the PHP script would have to be set to be accessible in this way, with hopefully some kind of provision to make sure that it can't be called by anyone else.