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 Code4 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