PHP Класс Contao\Files

The class handles file operations, either directly via the PHP functions or through an FTP connection. The latter is a workaround for insufficient file permissions when the PHP process runs under a different user than the file owner (referred to as "Safe Mode Hack"). Usage: $files = Files::getInstance(); $files->mkdir('test'); $files->fopen('test/one.txt', 'wb'); $files->fputs('My test'); $files->fclose(); $files->rrdir('test');
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$objInstance Files Object instance (Singleton)

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

Метод Описание
__clone ( ) Prevent cloning of the object (Singleton)
chmod ( string $strFile, mixed $varMode ) : boolean Change the file mode
copy ( string $strSource, string $strDestination ) : boolean Copy a file or folder
delete ( string $strFile ) : boolean Delete a file
fclose ( resource $resFile ) : boolean Close a file handle
fopen ( string $strFile, string $strMode ) : resource Open a file and return the handle
fputs ( resource $resFile, string $strContent ) Write content to a file
getInstance ( ) : Files Instantiate the object (Factory)
is_writeable ( string $strFile ) : boolean Check whether a file is writeable
mkdir ( string $strDirectory ) : boolean Create a directory
move_uploaded_file ( string $strSource, string $strDestination ) : boolean Move an uploaded file to a folder
rcopy ( string $strSource, string $strDestination ) Recursively copy a directory
rename ( string $strOldName, string $strNewName ) : boolean Rename a file or folder
rmdir ( string $strDirectory ) : boolean Remove a directory
rrdir ( string $strFolder, boolean $blnPreserveRoot = false ) Recursively remove a directory

Защищенные методы

Метод Описание
__construct ( ) Prevent direct instantiation (Singleton)
validate ( ) Validate a path

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

__clone() закрытый публичный Метод

Prevent cloning of the object (Singleton)
final public __clone ( )

__construct() защищенный Метод

Prevent direct instantiation (Singleton)
protected __construct ( )

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

Change the file mode
public chmod ( string $strFile, mixed $varMode ) : boolean
$strFile string The file name
$varMode mixed The new file mode
Результат boolean True if the operation was successful

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

Copy a file or folder
public copy ( string $strSource, string $strDestination ) : boolean
$strSource string The source file or folder
$strDestination string The new file or folder path
Результат boolean True if the operation was successful

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

Delete a file
public delete ( string $strFile ) : boolean
$strFile string The file name
Результат boolean True if the operation was successful

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

Close a file handle
public fclose ( resource $resFile ) : boolean
$resFile resource The file handle
Результат boolean True if the operation was successful

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

Open a file and return the handle
public fopen ( string $strFile, string $strMode ) : resource
$strFile string The file name
$strMode string The operation mode
Результат resource The file handle

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

Write content to a file
public fputs ( resource $resFile, string $strContent )
$resFile resource The file handle
$strContent string The content to store in the file

getInstance() публичный статический Метод

Instantiate the object (Factory)
public static getInstance ( ) : Files
Результат Files The files object

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

Check whether a file is writeable
public is_writeable ( string $strFile ) : boolean
$strFile string The file name
Результат boolean True if the file is writeable

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

Create a directory
public mkdir ( string $strDirectory ) : boolean
$strDirectory string The directory name
Результат boolean True if the operation was successful

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

Move an uploaded file to a folder
public move_uploaded_file ( string $strSource, string $strDestination ) : boolean
$strSource string The source file
$strDestination string The new file path
Результат boolean True if the operation was successful

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

Recursively copy a directory
public rcopy ( string $strSource, string $strDestination )
$strSource string The source file or folder
$strDestination string The new file or folder path

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

Rename a file or folder
public rename ( string $strOldName, string $strNewName ) : boolean
$strOldName string The old name
$strNewName string The new name
Результат boolean True if the operation was successful

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

Remove a directory
public rmdir ( string $strDirectory ) : boolean
$strDirectory string The directory name
Результат boolean True if the operation was successful

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

Recursively remove a directory
public rrdir ( string $strFolder, boolean $blnPreserveRoot = false )
$strFolder string The directory name
$blnPreserveRoot boolean If true, the root folder will not be removed

validate() защищенный Метод

Validate a path
protected validate ( )

Описание свойств

$objInstance защищенное статическое свойство

Object instance (Singleton)
protected static Files,contao $objInstance
Результат Files