File

The File helper file contains functions that assist in working with files and folders.

copy

Copy file.

file_helper::copy('path/to/source.txt', '/path/to/target.txt');

rename

Rename file.

file_helper::rename('path/to/old.txt', '/path/to/new.txt');

getMime

Get file's mime value.

file_helper::getMime('/path/to/file.txt'); // text/plain

scanFileNames

Scan folder and return array with file names.

file_helper::scanFileNames('path/to/folder');

scanDirectoryNames

Scan folder and return array with folder names.

file_helper::scanDirectoryNames('/path/to/folder');

download

Send file download request to the client.

file_helper::download('/path/to/folder', 'file.txt'); // download file as file.txt
file_helper::download('/path/to/folder', 'file.txt', 'new_file.txt'); // download file as new_file.txt

downloadURL

Download file from the URL.

file_helper::downloadURL('http://www.example.com/file.txt', '/path/to/folder/file.txt'); // download file as file.txt
file_helper::downloadURL('http://www.example.com/file.txt', '/path/to/folder/file.txt', 'new_file.txt'); // download file as new_file.txt
file_helper::downloadURL('http://www.example.com/file.txt', '/path/to/folder/file.txt', '', 1048576); // download file if it's smaller than 1mb