PHP Upload (i)

Source: Internet
Author: User
Tags http post

Summary of basic knowledge of PHP uploads

1.File Upload1The principle of File upload: The files on the client are uploaded to the server via the browser, and the files on the server are moved to the specified directory. 2"Client Configuration Form page, browse box method= ' Post 'enctype= ' Multipart/form-data ' 3"server-side configuration$_files:Accept upload File information$_files[' Browse box name '] [' Name ']->name of the uploaded file$_files[' Browse box name '] [' Type ']->MIME type of upload file$_files[' Browse box name '] [' Tmp_name ']->Server-Side temp file name$_files[' Browse box name '] [' Size ']->the size of the uploaded file, in bytes$_files[' Browse box name '] [' Error ']->Upload file Error number upload file error number:0 or UPLOAD_ERR_OK:represents no error, proving that the file on the client was sent to server side 1 or upload_err_ini_size: exceeds the maximum size of files allowed to be uploaded by php config file, upload_max_filesize=the value of option 2 or Upload_err_form_size:exceeds the maximum size of the upload file in the form, exceeding the value of the Max_file_size option 3 or upload_err_partial:file part is uploaded 4 or upload_err_no_file:no option to upload file 6 or Upload_err_no_tmp_dir:No temp directory found 7 or Upload_err_cant_write:directory cannot write 8 or upload_err_extension:because the PHP extension interrupted the file upload and file upload configuration information about: File_uploads= ON,support for uploading files in HTTP form Upload_tmp_dir=temporary directory for uploading files Upload_max_filesize=2M, set the maximum size of the uploaded file Post_max_size=8M, set the maximum value of the form to send data as post Max_file_uploads= 20, up to how many files can be uploaded at a time$_files is an empty array, uploading a file as an array (), without the possibility of uploading the file information:1form, method and Enctype2"file_uploads whether to open boolMove_uploaded_file($tmp _name,$destination):move the server-side temporary files to the specified directory, what is the name; move succeeded, return true, fail false3"Upload file limit client limit limit upload file size<input type= ' hidden ' name= ' max_file_size ' value= ' file size, Unit bytes '/>limit upload file types<input type= ' file ' name= ' myFile ' accept= ' The MIME type of the uploaded file, between multiple types, separated '/>MIME type extension MIME type jpg for commonly used files/jpeg image/jpeg gif image/gif png image/png HTML text/HTML txt text/Plain PDF Application/PDF Restrictions on the client can be bypassed server-side limit limit upload file size limit upload file type limit is through HT TP Post method Upload detection is true picture//1. Receive information//2. Determine the error number (Error matching error)//3. Detects the size of the uploaded file//4. Detects the type of upload file//5. Detects if the file was uploaded via HTTP post 6. Last Move file

PHP Upload (i)

Related Article

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.