PHP instance four file upload

Source: Internet
Author: User
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.

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