| API | Package | Subpackage | Class | Method | Reference | Last reviewed | Doc status |
|---|---|---|---|---|---|---|---|
Home |
Joomla.Framework |
FileSystem |
JFile |
delete |
delete() |
Never | Work in Progress |
Delete a file or array of files. If FTP is enabled and safe mode is on or the file(s) are unwritable by the web server user, then the function will use FTP to delete the file(s). Otherwise, the function will use the PHP unlink function. The function returns true if all files were deleted. Otherwise, it returns false.
boolean delete ( $file )
| $file | mixed | is a string or an array of strings that contains the file name or an array of file names. |
Example 1: This example deletes a file.
Example 1
if (JFile::delete( 'images/stories/clock_copy.jpg' )) { echo "<h3>File(s) Successfully Deleted</h3>"; } else { echo "<h3>Could not delete one or more files</h3>"; }
Example 2: This example deletes two files.
Example 2
$files = array( 'images/stories/clock_copy1.jpg', 'images/stories/clock_copy2.jpg' ); if (JFile::delete( $files )) { echo "<h3>File(s) Successfully Deleted</h3>"; } else { echo "<h3>Could not delete one or more files</h3>"; }