Here's the form code:
;
This is the upload.php code:
0) {echo ' upload error: '; Switch ($_files[' myfile ' [' Error ']) {case 1:die (' upload size exceeded limit: upload_max_filesize '); Case 2:die (' upload size exceeds the contract value in the form: Max_file_size '); Case 3:die (' file only partially uploaded! '); Case 4:die (' did not upload any files! '); Default:die (' unknown error '); }} $linshi =explode (".", $_files[' myfile ' [' name ']);//Determine whether the uploaded file conforms to the allowable format $hz = Array_pop ($linshi);//array Gets the name of the file including the extension// The method is to determine the suffix if (!in_array ($hz, $allowtype)) {die ("this suffix{$hz}is not a permitted file type "); }//determine if the size matches if ($_files[' myfile '] [' size ']> $size) {die (' exceeds the allowed{$size}byte size '); }//$filename = Date ("Ymdhis"). Rand (100,999). ".". $hz; if (Is_uploaded_file ($_files[' myfile ' [' tmp_name '])) {if (!move_uploaded_file ' $_files[' [' myfile '], $path .' /'. $_files[' myfile ' [' name ']) {die (' cannot move the file to the specified directory! '); }}else {die (' not specified file! '); } echo "
"; echo "Hello!
"; echo" your file: {$_files[' myfile ' [' Name ']} has been uploaded successfully! The size is {$_files[' myfile ' [' Size ']} bytes! "Echo" we will promptly process and contact you, please wait patiently. "; Echo"
"Echo" Back Home "; echo"
";? >
The above describes the PHP instance four file upload, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.