The file helper contains methods that assist in working with files.
Returns true if the File exists.
if (File::exists('filename.txt')) { // Do something... }
Rename file.
File::rename('filename1.txt', 'filename2.txt');
Delete file.
File::delete('filename.txt');
Copy file.
File::copy('folder1/filename.txt', 'folder2/filename.txt');
Get the File extension.
echo File::ext('filename.txt');
Get the File name.
echo File::name('filename.txt');
Get list of files in directory recursive.
$files = File::scan('folder'); $files = File::scan('folder', 'txt'); $files = File::scan('folder', array('txt', 'log'));
Fetch the content from a file or URL.
echo File::getContent('filename.txt');
Writes a string to a file.
File::setContent('filename.txt', $content);
Get time(in Unix timestamp) the file was last changed.
echo File::lastChange('filename.txt');
Get last access time.
echo File::lastAccess('filename.txt');
Returns the mime type of a file. Returns false if the mime type is not found.
echo File::mime('filename.txt');
Forces a file to be downloaded.
File::download('filename.txt');
Display a file in the browser.
File::display('filename.txt');
Tests whether a file is writable for anyone.
if (File::writable('filename.txt')) { // do something... }