PHP file to pass simple code

Source: Internet
Author: User
Tags php file upload
PHP File Upload Simple code
1. Program Files
 
  m.jpg [Type] = Image/jpeg [Tmp_name] = C:\WINDOWS\Temp\php1A.tmp [ERROR] = 0 [size] = 44905) $name = $upfile ["Name"];//facilitates the later transfer of the file when the name $type= $upfile ["type"];//the types of uploaded files $size= $upfile ["Size"];//upload the file sizes $tmp_name= $upfile ["Tmp_ Name "];//the temporary name of the user to upload the file $error= the error message in the upload process $upfile [" Error "];////echo $name;//Determine the file type, determine whether to transfer the file, if required, set $ok= 1 can transfer switch ($type) {case "image/jpg": $ok =1;break;case "image/jpeg": $ok =1;break;case "image/gif": $ok =1;break; Default: $ok =0;break;} If the file meets the requirements and there is no error during the upload process ($ok && $error = = ' 0 ') {//Call Move_uploaded_file () function, file transfer Move_uploaded_file ($tmp _ Name, ' up/'. $name);//After successful operation, the prompt is successful, echo "";} else{//If the file does not conform to the type or the upload process has errors, the prompt fails echo "";}? >

If you want to implement a more powerful upload program, such as multi-file, multi-image upload function, you can refer to this article:
Http://www.jbxue.com/article/6378.html

2. Upload page
 
  
  • 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.