Write a form file upload.html:
Upload a new fileUpload a new file
Files that process the form: upload.php
<title><strong> Uploading Files </strong></title>
0) {echo ' problem: '; Switch ($_files[' userfile ' [' Error ']) {case 1:echo ' file exceeds upload_max_filesize '; Break Case 2:echo ' file exceeds max_file_size '; Break Case 3:echo ' file is only part of the upload '; Break Case 4:echo ' no file upload '; Break Case 6:echo ' can'tUploading Files: No temp directory specified '; Break Case 7:echo 'Uploading FilesFailed: Cannot write to disk '; Break } exit; Determine if the file is not the correct MIME format if ($_files[' userfile ' [' type ']! = ' Text/plain ') {echo ' problem: File is not plain text '; Exit;} Place the file at the specified location $upfile= ' uploads/'. $_files[' userfile ' [' Name '];if (is_uploaded_file ($_files[' userfile '] [' tmp_name '] ) {if (!move_uploaded_file ($_files[' userfile '] [' tmp_name '], $upfile)) {echo ' problem: Cannot move file to the specified folder '; Exit }}else{echo ' problem: file may be affected. File name: '; echo $_files[' userfile ' [' name ']; Exit;} echo ' File upload succeeded
'; $c $cfile_put_contents ($_files[' userfile ' [' name '], $contents); Echo 'Browse the contents of the uploaded file:
'; Echo nl2br ($contents); Echo '
';? >
The above is the introduction of PHP file upload, including the content of uploading files, I hope that the PHP tutorial interested in a friend helpful.