PHP File Upload Simple code
1. Program Files
m.jpg [Type] = Image/jpeg [Tmp_name] = C:\WINDOWS\Temp\php1A.tmp [ERROR] = 0 [size] = 44905) $name = $upfile ["Name"];//facilitates the later transfer of the file when the name $type= $upfile ["type"];//the types of uploaded files $size= $upfile ["Size"];//upload the file sizes $tmp_name= $upfile ["Tmp_ Name "];//the temporary name of the user to upload the file $error= the error message in the upload process $upfile [" Error "];////echo $name;//Determine the file type, determine whether to transfer the file, if required, set $ok= 1 can transfer switch ($type) {case "image/jpg": $ok =1;break;case "image/jpeg": $ok =1;break;case "image/gif": $ok =1;break; Default: $ok =0;break;} If the file meets the requirements and there is no error during the upload process ($ok && $error = = ' 0 ') {//Call Move_uploaded_file () function, file transfer Move_uploaded_file ($tmp _ Name, ' up/'. $name);//After successful operation, the prompt is successful, echo "";} else{//If the file does not conform to the type or the upload process has errors, the prompt fails echo "";}? >
If you want to implement a more powerful upload program, such as multi-file, multi-image upload function, you can refer to this article:
Http://www.jbxue.com/article/6378.html
2. Upload page