CFile Class
This class is used to handle files and images.
Equivalent to class in the new core D7 - Bitrix\Main\FileTable.
Fields
Field | Type | Description |
---|---|---|
ID | int | The file ID. |
TIMESTAMP_X | timestamp | Date when record was modified. |
MODULE_ID | varchar(50) | Module ID to which the file belongs. |
HEIGHT | int | Image height (image file). |
WIDTH | int | Image width (image file). |
FILE_SIZE | int | File size (bytes). |
CONTENT_TYPE | varchar(255) | File MIME type. |
SUBDIR | varchar(255) | Subdirectory containing the file. Main directory for file storage is set in the parameter "File upload default folder" in the Kernel module settings. You can obtain the value of this parameter by the following call:
COption::GetOptionString("main", "upload_dir", "upload"); |
FILE_NAME | varchar(255) | File name of the server. |
ORIGINAL_NAME | varchar(255) | Original name of the file, when it was uploaded to the server. |
DESCRIPTION | varchar(255) | File description. |
Class methods
Method | Description | Available from version |
---|---|---|
GetByID | Returns information on a registered file. | |
GetList | Returns sorted and filtered selection of registered files. | |
GetPath | Returns the root path of a registered file. | |
[link= 6658201]ShowImage[/link] | Returns the HTML code that can be used to display an image file. | |
Show2Images | Returns the HTML code used to display a smaller image with a link which opens a new window with a larger image. | |
CheckFile | Verifies the size, extension and mime type of the file. Returns string with error text on failure. | |
CheckImageFile | Ensures the file is an image and checks its parameters. Returns string with error text on failure. | |
IsImage | Checks the file extension and MIME type. Returns true if the file extension and type corresponds to an image file; otherwise, returns failure. | |
MakeFileArray | Creates an array describing a single file. Structure of the array is similar to that of $_FILES[name] (or $HTTP_POST_FILES[name]). This array can be used with CFile::SaveFile, CFile::CheckFile, CFile::CheckImageFile methods. | |
InputFile | Returns the HTML form code that can be used to upload a new or replace an existing file. | |
SaveFile | Saves file and registers it in the file table. | |
SaveForDB | Saves file and prepares data to insert/update a record in the database, containing link to the file. | |
UpdateDesc | Updates the registered file description. | |
CopyFile | Copies the registered file. | |
Delete | Removes file from the file registrar table and deletes it from the disk. | |
FormatSize | Converts bytes into units with account of the language, installed in the current site. | |
GetFileArray | Returns an array describing file with the specified identifier. | |
ResizeImageFile | Modifies size of image file | |
ResizeImageGet | Reduces size of image file. | |
ResizeImage | Wrapper for ResizeImageFile |
© «Bitrix24», 2001-2024