PHP Класс Files

Наследование: extends Controller
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
copyFile ( string $source, string $destination_dir, string $destination_file, boolean $unique = true ) : string Copy a file from source to destination. If unique == true, then if the destination exists, it will be renamed by appending an increamenting counting number.
createFolder ( string $newFolder ) : boolean Create a new folder.
delFile ( string $file ) : boolean Delete a file.
delFolder ( string $folder, boolean $recursive = false ) : boolean Delete folder(s), can delete recursively.
escape ( string $filename ) : string Escape the filenames, any non-word characters will be replaced by an underscore.
fixPath ( string $path ) : string Append a / to the path if required.
formatSize ( integer $size ) : string Format the file size, limits to Mb.
makeFile ( string $pathA, string $pathB ) : string Similar to makePath, but the second parameter is not only a path, it may contain say a file ending.
makePath ( string $pathA, string $pathB ) : string Concat two paths together. Basically $pathA+$pathB

Описание методов

copyFile() публичный Метод

Copy a file from source to destination. If unique == true, then if the destination exists, it will be renamed by appending an increamenting counting number.
public copyFile ( string $source, string $destination_dir, string $destination_file, boolean $unique = true ) : string
$source string where the file is from, full path to the files required
$destination_dir string where the files, just the destination dir, e.g., /www/html/gallery/
$destination_file string name of the new file, just the filename
$unique boolean create unique destination file if true.
Результат string the new copied filename, else error if anything goes bad.

createFolder() публичный Метод

Create a new folder.
public createFolder ( string $newFolder ) : boolean
$newFolder string specifiy the full path of the new folder.
Результат boolean true if the new folder is created, false otherwise.

delFile() публичный Метод

Delete a file.
public delFile ( string $file ) : boolean
$file string file to be deleted
Результат boolean true if deleted, false otherwise.

delFolder() публичный Метод

Delete folder(s), can delete recursively.
public delFolder ( string $folder, boolean $recursive = false ) : boolean
$folder string the folder to be deleted.
$recursive boolean if true, all files and sub-directories are delete. If false, tries to delete the folder, can throw error if the directory is not empty.
Результат boolean true if deleted.

escape() публичный Метод

Escape the filenames, any non-word characters will be replaced by an underscore.
public escape ( string $filename ) : string
$filename string the orginal filename
Результат string the escaped safe filename

fixPath() публичный Метод

Append a / to the path if required.
public fixPath ( string $path ) : string
$path string the path
Результат string path with trailing /

formatSize() публичный Метод

Format the file size, limits to Mb.
public formatSize ( integer $size ) : string
$size integer the raw filesize
Результат string formated file size.

makeFile() публичный Метод

Similar to makePath, but the second parameter is not only a path, it may contain say a file ending.
public makeFile ( string $pathA, string $pathB ) : string
$pathA string the leading path
$pathB string the ending path with file
Результат string combined file path.

makePath() публичный Метод

Concat two paths together. Basically $pathA+$pathB
public makePath ( string $pathA, string $pathB ) : string
$pathA string path one
$pathB string path two
Результат string a trailing slash combinded path.