Bitrix Site Manager

CPosting::SaveFile

CPosting::SaveFile(
    int ID,
    array file
);

The method SaveFile adds an attachment to an issue. The attachment is stored and registered in the file table (b_file).

Parameters

ParameterDescription
ID The issue ID.
file Array of file data in the format:
Array(
    "name" => "file name",
    "size" => "size",
    "tmp_name" => "temporary path on the server",
    "type" => "file type");
You can obtain this array directly from $_FILES[field_name].

Return Values

Retuns the ID of the registered file on success, or false otherwise.

Example



if (strlen($save)>0 && $REQUEST_METHOD=="POST")
{
    $file_id = CPosting::SaveFile($ID, $_FILES["FILE_TO_ATTACH"]);
    if ($file_id===false)
        strError .= "Error storing the attachement."."<br>";
}