Documentation

File


The file helper contains methods that assist in working with files.


Methods


exists(string $filename)


Returns true if the File exists.


if (File::exists('filename.txt')) {
    // Do something...
}

rename(string $from, string $to)


Rename file.


File::rename('filename1.txt', 'filename2.txt');

delete(string $filename)


Delete file.


File::delete('filename.txt');

copy(string $from, string $to)


Copy file.


File::copy('folder1/filename.txt', 'folder2/filename.txt');

ext(string $filename)


Get the File extension.


echo File::ext('filename.txt');

name(string $filename)


Get the File name.


echo File::name('filename.txt');

scan(string $folder, [mixed $type = null])


Get list of files in directory recursive.


$files = File::scan('folder');
$files = File::scan('folder', 'txt');
$files = File::scan('folder', array('txt', 'log'));

getContent(string $filename)


Fetch the content from a file or URL.


echo File::getContent('filename.txt');

setContent(string $filename, string $content, [boolean $create_file = true, [boolean $append = true, [integer $chmod = 0666]]])


Writes a string to a file.


File::setContent('filename.txt', $content);

lastChange(string $filename)


Get time(in Unix timestamp) the file was last changed.


echo File::lastChange('filename.txt');

lastAccess(string $filename)


Get last access time.


echo File::lastAccess('filename.txt');

mime(string $file, [boolean $guess = true])


Returns the mime type of a file. Returns false if the mime type is not found.


echo File::mime('filename.txt');

download(string $file, [string $content_type = null, [string filename = null, [integer $kbps = 0]]])


Forces a file to be downloaded.


File::download('filename.txt');

display(string $file, [string $content_type = null, [string filename = null]])


Display a file in the browser.


File::display('filename.txt');

writable(string $file)


Tests whether a file is writable for anyone.


if (File::writable('filename.txt')) {
   // do something...
}