PHP File Upload

Source: Internet
Author: User
Tags php file upload
Write a form file upload.html:

    
 
      Upload a new file

Upload 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.

  • 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.