Bitrix Site Manager

CFile

The CFile class is used to handle files and images.

Fields

Field Type Description
ID int The file ID.
TIMESTAMP_X timestamp Record modification date.
MODULE_ID varchar(50) The ID of the module to which the file belongs.
HEIGHT int Image height (for image files).
WIDTH int Image width (for image files).
FILE_SIZE int File size (bytes).
CONTENT_TYPE varchar(255) File MIME type.
SUBDIR varchar(255) Directory containing the file. Base directory used 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 on the server.
ORIGINAL_NAME varchar(255) Original name of the file, as it has been uploaded to the server.
DESCRIPTION varchar(255) File description.

Methods

MethodDescription
GetByID Returns information on a registered file.
GetPath Returns the root path of a registered file.
ShowImage 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.
CheckImageFile Ensures the file is an image and checks its parameters.
IsImage Checks the file extension and MIME type. Returns true if the file extension and type corresponds to an image file.
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 methods SaveFile, CheckFile, CheckImageFile
InputFile Returns the HTML form code that can be used to upload a new or replace an existing file.
SaveFile Saves a file and registers it in the file table.
UpdateDesc Updates the registered file description.
CopyFile Copies the registered file and returns the ID of a copy.
Delete Removes a file from the file registrar table and deletes it from the disk.