This class provides several functions to work with files and folders.
Here is a list of available public methods for this class:
Read a directory and return containing filenames as array.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$directory | String | Name of directory. |
File::read_directory('downloads');
Get size from a file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$file | String | Full path and name of given file. | ||
$human_readable | boolean | Set true to return filesize as human readable string. |
File::size('downloads', true);
Rename directory or file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$current_filename | String | Path to file or directory to rename. | ||
$new_filename | String | New path. |
File::rename('downloads/foo.txt', 'downloads/bar.txt');
Alias for rename()
File::rename_directory('downloads', 'download');
Copy file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$source_file | String | file to copy. | ||
$new_directory | String | Target directory. |
File::copy('download/test.js', 'assets/js/test.js');
Delete file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$file | String | path to file to delete. |
File::delete('download/test.js');
Delete directory. If the directory is not empty, false will returned; exept if you set the second parameter to true.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$directory | String | directory to delete. | ||
$delete_files | boolean | delete containing files. |
File::delete_directory('download');
Get the last modified date and time for given file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$file | String | File. | ||
$date_format | string | 'Y-m-d' | Set the date format. | |
$timestamp | boolean | false | If set to true, timestamp instead of date will be returned. |
File::get_last_modified(index.php');