PHP File Upload

Source: Internet
Author: User

 Public "-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
View Code
<?PHPVar_dump($_files["File"]);//image/jpeg,image/png//1. Control the upload file type and size//2. If the file name recurs, overwrite//3. method to reduce the probability of duplicate filenames 1. Modify the FileName Method 2. Build folder//4. About the Chinese garbled problemif(($_files["File"] ["Type"]== "Image/jpeg" | |$_files["File"] ["Type"]== "Image/png") &&$_files["File"] ["Size"]<=102400){    //upload operation//Create a storage path    $yuan=$_files["File"] ["Tmp_name"]; $filename= "./img/".Date("Ymdhis").$_files["File"] ["Name"]; //change the encoding format of the storage path to GB    $filename=Iconv("UTF-8", "gb2312",$filename); //determine if a file exists    if(file_exists($filename))    {         die("File already exists"); }    //Moving Files    Move_uploaded_file($yuan,$filename); }Else{    Echo"Upload file does not meet the requirements"; }
View Code

4 All aspects

1. Control the upload file type and size
2. Overwrite if file name recurs
3. The probability method to reduce the name of the file 1. Modify the FileName Method 2. Create a folder
4. About the Chinese garbled problem

PHP File Upload

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.