_php tutorial on the important functions of $_files files in PHP

Source: Internet
Author: User
$_files["File" ["Name"]-the name of the file being uploaded
$_files["File" ["type"]-the type of file being uploaded
$_files["File" ["Size"]-the size of the uploaded file, measured in bytes
$_files["File" ["Tmp_name"]-the name of the temporary copy of the file stored on the server
$_files["File" ["Error"]-error code caused by file upload


PHP code

!--? php

If (($_files["File" ["type"] = = "Image/gif")
| | ($_files["File" ["type"] = = "Image/jpeg")
| | ($_files["File" ["type"] = = "Image/pjpeg"))
&& ($_files["File" ["Size"] < 20000))
{
if ($_files["file" ["error"] > 0)
{
echo "error:". $_files["File" ["Error"]. "
";
}
Else
{
echo "upload:". $_files["File" ["Name"]. "
";
echo "type:". $_files["File" ["type"]. "
";
echo "Size:". ($_files["File" ["Size"]/1024). "KB
";
echo "stored in:". $_files["File" ["Tmp_name"];
}
}
Else
{
echo "invalid file";
}

?

The contents of the $_files array are as follows:
$_files[' myfile ' [' Name '] The original name of the client file.
The MIME type of the $_files[' myfile ' [' type '] file requires the browser to provide support for that information, such as "Image/gif".
$_files[' myfile ' [' size '] the size of the uploaded file, in bytes.
$_files[' myfile ' [' tmp_name '] files are uploaded after the temporary file name stored on the server, usually the system default. Can be specified in the php.ini upload_tmp_dir, but the putenv () function setting is not working.
$_files[' myfile ' [' Error '] and the file upload related error code. [' ERROR '] was added in version php 4.2.0. Here is a description of it: (they become constants after php3.0)
Upload_err_ok
Value: 0; No error occurred and the file upload was successful.
Upload_err_ini_size
Value: 1; The uploaded file exceeds the value of the Upload_max_filesize option limit in php.ini.
Upload_err_form_size
Value: 2; The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
Upload_err_partial
Value: 3; Only part of the file is uploaded.
Upload_err_no_file
Value: 4; No files were uploaded.
Value: 5; The upload file size is 0.


http://www.bkjia.com/PHPjc/445362.html www.bkjia.com true http://www.bkjia.com/PHPjc/445362.html techarticle $_files[file][name]-the name of the uploaded file $_files[file][type]-the type of file being uploaded $_files[file][size]-the size of the uploaded file, in bytes $_files[file][tmp _name] ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.