: This article mainly introduces php file upload. For more information about PHP tutorials, see. Write a single table file upload.html:
Upload new filesUpload new files
Process the Form File: upload. php
<Strong> upload a file </strong>
0) {echo 'problem: '; switch ($ _ FILES ['userfile'] ['error']) {case 1: echo' The file exceeds upload_max_filesize '; break; case 2: echo 'file exceeds max_file_size '; break; case 3: echo' only part of the file is uploaded '; break; case 4: echo 'No file upload'; break; case 6: echo 'noUpload files: No temporary directory specified '; break; case 7: echo'Upload filesFailed: Cannot write to disk '; break;} exit;} // Determine whether the file is in the correct MIME format if ($ _ FILES ['userfile'] ['type']! = 'Text/plain ') {echo 'problem: The file is not plain text'; exit;} // place the file in the specified place $ upfile = 'uploads /'. $ _ FILES ['userfile'] ['name']; if (is_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name']) {if (! Move_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name'], $ upfile) {echo 'problem: the file cannot be moved to the specified folder '; exit ;}} else {echo 'problem: The file may be affected. File name: '; echo $ _ FILES ['userfile'] ['name']; exit;} echo' file uploaded successfully
'; $ C $ cfile_put_contents ($ _ FILES ['userfile'] ['name'], $ contents); echo'View the content of the uploaded file:
'; Echo nl2br ($ contents); echo'
';?>
The above introduces php file upload, including file upload content. I hope my friends who are interested in PHP tutorials will be helpful.