Php file Upload

Source: Internet
Author: User
Tags php file upload
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.