CFile Class

This class is used to handle files and images.

Equivalent to class in the new core D7 - Bitrix\Main\FileTable.


IDintThe file ID.
TIMESTAMP_XtimestampDate when record was modified.
MODULE_IDvarchar(50)Module ID to which the file belongs.
HEIGHTintImage height (image file).
WIDTHintImage width (image file).
FILE_SIZEintFile size (bytes).
CONTENT_TYPEvarchar(255)File MIME type.
SUBDIRvarchar(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_NAMEvarchar(255)File name of the server.
ORIGINAL_NAMEvarchar(255)Original name of the file, when it was uploaded to the server.
DESCRIPTIONvarchar(255)File description.

Class methods

MethodDescriptionAvailable from version
GetByIDReturns information on a registered file.
GetListReturns sorted and filtered selection of registered files.
GetPathReturns the root path of a registered file.
[link= 6658201]ShowImage[/link]Returns the HTML code that can be used to display an image file.
Show2ImagesReturns the HTML code used to display a smaller image with a link which opens a new window with a larger image.
CheckFileVerifies the size, extension and mime type of the file. Returns string with error text on failure.
CheckImageFileEnsures the file is an image and checks its parameters. Returns string with error text on failure.
IsImageChecks the file extension and MIME type. Returns true if the file extension and type corresponds to an image file; otherwise, returns failure.
MakeFileArrayCreates 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.
InputFileReturns the HTML form code that can be used to upload a new or replace an existing file.
SaveFileSaves file and registers it in the file table.
SaveForDBSaves file and prepares data to insert/update a record in the database, containing link to the file.
UpdateDescUpdates the registered file description.
CopyFileCopies the registered file.
DeleteRemoves file from the file registrar table and deletes it from the disk.
FormatSizeConverts 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