Name: delete URL

Type: command

Syntax: delete URL <URLtoDelete> 

Summary: Removes a <file> or <folder|directory> from a <server>, or removes a <file> from your system.

Synonyms: clear URL

Introduced: 1.1

OS: mac,windows,linux,ios,android

Platforms: desktop,server,web,mobile

Security: network

Example:
delete URL "ftp://root:secret-word@mars.example.org/deleteable.txt"

Example:
delete URL "ftp://me:mine@ftp.example.net/trash/"

Example:
answer file "Select the file you wish to delete."
put it into tFileToDelete
delete URL ("file:" & tFileToDelete)

Parameters:
URLtoDelete: The URLtoDelete specifies the name and location of the file or directory to delete, in the form of a URL.

The result: If the file or directory is successfully deleted, the result <function> is set to empty. Otherwise, the <result> <function> returns an error message. >*Important:* If a <blocking> operation involving a <URL> (using the <put> <command> to <upload> a <URL>, the <post> <command>, the <delete URL> <command>, or a <statement> that gets an <ftp> or <http> <URL>) is going on, no other <blocking> <URL> operation can start until the previous one is finished. If you attempt to use a <URL> in an <expression>, or put data into a <URL>, while another <blocking> <URL> operation is in progress, the <result> is set to "Error Previous request not completed".

Description:
Use the <delete URL> <command> to remove a <file>.

You can use a <file> or <binfile> <URL> to delete a <file>, but not a <folder>. To remove a <folder> from your system, use the <delete folder> <command>. (You can also use the <delete file> command to delete a <local file>.)

This command can also be used to remove files and directories your stack did not create. Of course, a stack should not remove data it didn't create without obtaining explicit confirmation from the user.

Normally, FTP servers do not allow anonymous users to delete files, for obvious reasons. This means that while an <ftp> <URL> without a user name and password is valid, you will almost always need a user name and password to use the <delete URL> <command>.

>*Note:*  When used with an <ftp> or <http> <URL>, the <delete URL> <command> is <blocking> : that is, the <handler> pauses until LiveCode is finished deleting the <URL>. Since deleting a file from a server may take some time due to network lag, the <delete URL> <command> may take long enough to be noticeable to the user.

>*Important:* The <delete URL> <command> is part of the <Internet library>. To ensure that the <command> works in a <standalone application>, you must include this <Revolution custom library|custom library> when you create your <standalone application|standalone>. In the Inclusions section of the <Standalone Application Settings> window, make sure "Internet Library" is selected in the list of script libraries.

>*Note:* When included in a <standalone application>, the <Internet library> is implemented as a hidden <group> and made available when the <group> receives its first <openBackground> message. During the first part of the <application|application's> startup process, before this <message> is sent, the <delete URL> <command> is not yet available. This may affect attempts to use this <command> in <startup>, <preOpenStack>, <openStack>, or <preOpenCard> <handler|handlers> in the <main stack>. Once the <application> has finished starting up, the <library> is available and the <delete URL> <command> can be used in any <handler>.

References: startup (message), openBackground (message), preOpenStack (message), openStack (message), preOpenCard (message), Revolution custom library (library), put (library), library (library), Internet library (library), binfile (keyword), ftp (keyword), file (keyword), URL (keyword), http (keyword), function (control_st), application (glossary), standalone application (glossary), statement (glossary), delete folder (glossary), blocking (glossary), Standalone Application Settings (glossary), command (glossary), expression (glossary), main stack (glossary), group (glossary), delete file (glossary), local file (glossary), server (glossary), upload (glossary), folder (glossary), message (glossary), handler (glossary), libURLSetFTPStopTime (command), post (command), delete file (command), delete folder (command), result (function)

Tags: networking
