PHP implementation of File upload source code
m.jpg [Type] = Image/jpeg [Tmp_name] = C:\WINDOWS\Temp\php1A.tmp [ERROR] = 0 [size] = 44905) $name = $upfile ["Name"];//is convenient for later transfer of a file $type = $upfile The type of the upload file $size = $upfile ["Size"];//the upload file $tmp _n Ame= $upfile ["Tmp_name"];//the temporary name of the user to upload the file $error = $upfile ["Error"];//errors in the upload process//echo $name; Judge the file type, determine whether to transfer the file, if required to 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 in the upload process if ($ok && $error = = ' 0 ') {//Call Move_uploaded_file () function for 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 if there is an error in the upload process, the message fails echo ""; }}?>
The above introduces the PHP implementation of File upload source code, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.