Documentation

MakeFileArray

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:

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

Static method.

Parameters

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"             => "user@mail.com",
  "SOURCE_SID"            => "email",
  "MESSAGE_AUTHOR_SID"    => "user@mail.com",
  "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(
                "SUBJECT"=>$SUBSCRIBE_TEMPLATE_RUBRIC["NAME"],
                "BODY_TYPE"=>"html",
                "CHARSET"=>"Windows-1251",
                "DIRECT_SEND"=>"Y",
                "FROM_FIELD"=>$SUBSCRIBE_TEMPLATE_RUBRIC["FROM_FIELD"],
                "GROUP_ID" => array(22,30),
                "FILES" => array(
                                CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/upload/our_price.xls")
                ),
        );


© «Bitrix24», 2001-2024