Bitrix Site Manager

CFile::InputFile

string
CFile::InputFile(
 string input_file_name,
 int input_file_width,
 int file_id,
 string file_path = false,
 int file_max_size = 0,
 string file_type = "IMAGE",
 string add_to_input_file = "class=typefile",
 int input_description_width = 0,
 string add_to_input_description = "class=typeinput",
 string add_to_checkbox_delete = "",
 bool show_file_info = true,
)

The method InputFile returns the HTML form code that can be used to upload a new or replace an existing file.

Parameters

ParameterDescription
input_file_name Name of the file input field:
<input type="file" name="input_file_name" ... >
input_file_width Width of the file input field:
<input type="file" size="input_file_width" ... >
file_id Numeric ID of the existing file.
file_path Root path of a folder to contain files. For example: "/upload/iblock/".

Optional. False by default, which means system settings are used.
file_max_size Maximum file size, in bytes:
<input type="hidden" name="MAX_FILE_SIZE" value="file_max_size">

Optional. The default value is "0", which means no restriction applies.
file_type File type. If "IMAGE", the file information will contain image dimensions.

Optional. The default value is "IMAGE".
add_to_input_file Arbitrary HTML code to insert in the file input tag:
<input type="file" add_to_input_file ... >

Optional. The default value is "class=typefile", which sets the common CSS selector for file input fields in the administrative section.
input_description_width Width of the file comment input field:
<input type="text" size="input_description_width" ... >

Optional. The default value is "0", which hides the comment field.
add_to_input_description Arbitrary HTML code to insert in the file comment input field:
<input type="text" add_to_input_description ... >

Optional. The default value is "class=typeinput", which sets the common CSS selector for single line text input fields in the administrative section.
add_to_checkbox_delete Arbitrary HTML code to insert in the file deletion checkbox field:
<input type="checkbox" name="input_file_name_del" value="Y" add_to_checkbox_delete ... >

Optional.
show_file_info Allows to show or hide the file information (size and dimensions).

Optional. The default value is true, which displays the file information.

See Also

Example



<tr valign="top">
    <td align="right"><font 
                       class="tablefieldtext">
                       <?=GetMessage("VOTE_IMAGE")?></font></td>
    <td><font class="tablebodytext"><?
    echo CFile::InputFile("IMAGE_ID", 20, $str_IMAGE_ID);
    if (strlen($str_IMAGE_ID)>0):
        ?><br><?echo CFile::ShowImage($str_IMAGE_ID, 
                                      200, 200, 
                                      "border=0", "", true);
    endif;
    ?></font>
    </td>
</tr>