array CFile::MakeFileArray(
 mixed path,
 mixed mime_type = false,
 skipInternal = false,
 string external_id = ""

The method 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 in the SaveFile, CheckFile, CheckImageFile methods. The structure of the returned array is the following:

    "name" => "file name",
    "size" => "size",
    "tmp_name" => "temporary path on the server",
    "type" => "file type")

Static method.


ParameterDescription Available from version
path one of values:
  • File ID
  • absolute path to file
  • URL to file located at the different site (on other server).
mime_type file MIME type (e. g., "image/gif").
Optional parameter. By default - "false" - file MIME type will be determined automatically.
skipInternal Optional parameter. By default - "false".
external_id Optional parameter. External ID.

See Also

Examples of use

$arFile = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/images/screen.gif");
$arFile["MODULE_ID"] = "support";
$arFields = array(
  "CREATED_MODULE_NAME"   => "mail",
  "MODIFIED_MODULE_NAME"  => "mail",
  "OWNER_SID"             => "",
  "SOURCE_SID"            => "email",
  "MESSAGE_AUTHOR_SID"    => "",
  "MESSAGE_SOURCE_SID"    => "email",
  "TITLE"                 => "title",
  "MESSAGE"               => "message"
  "FILES"                 => array($arFile)
//$TICKET_ID = 866;
$NEW_TICKET_ID = CTicket::Set($arFields, $MESSAGE_ID, $TICKET_ID, "N");

How to attach a file to an automatic mailing. The file must be added to the mail via the [link=91213]BeforePostingSendMail[/link] event and the [link=91177]CPosting::SaveFile[/link] method. The "return array" code is available in the 'news' template (available by default). The FILES element must be added to this array.

        return array(
                "GROUP_ID" => array(22,30),
                "FILES" => array(

© «Bitrix24», 2001-2022