Documentation

CheckImageFile

string
CFile::CheckImageFile(
 array file,
 int max_size = 0,
 int max_width = 0,
 int max_height = 0
 array access_typies = array(),
 bool ForceMD5=false, 
 bool SkipExt=false
)

The method ensures the file is an image and checks its parameters. In case of an error, the method returns a string containing the error description. Static method.

Parameters

ParameterDescription Available from version
file Array with format file data:
Array(
    "name" => "file name",
    "size" => "size",
    "tmp_name" => "temporary path 
                   to file on the server",
    "type" => "type of loaded file",
    "del" => "flag: delete the existing file  
              from the data base (Y|N)",
    "MODULE_ID" => "module name")
Array of this type can be obtained, for example, by joining the arrays $_FILES[field name] and Array("del" => ${"field name"."_del"}, "MODULE_ID" = "module name").
max_size Maximum file size (bytes).
Optional parameter. The default value is "0", no restrictions applied.
max_width Maximum image width (pixels).
Optional parameter. The default value is "0", no restrictions applied.
max_height Maximum image height (pixels).
Optional parameter. The default value is "0", no restrictions applied.
access_typies Array of symbolic identifiers for file types; the following IDs are available:
  • IMAGE - image;
  • FLASH - flash file.
Optional parameter. The default value - empty array (only files of IMAGE type are available).
ForceMD5 Optional parameter. The default value - "false".
SkipExt Optional parameter. The default value - "false".

See Also

Examples of use

<?
$arrFile = array_merge(
    $_FILES["ATTACHED_IMAGE"], 
    array("del" => ${"ATTACHED_IMAGE_del"}, "MODULE_ID" => "forum"));

$res = CFile::CheckImageFile($arrFile, 200, 50, 50);
if (strlen($res)>0) $strError .= $res."<br>";
?>


© «Bitrix24», 2001-2022
Up