This article is mainly to share with you PHP file upload Simple example, I hope to help everyone.
# #文件上传1. In the form header to write enctype= "Multipart/form-data"; 2. It is best to define a hidden hidden,name= "max_file_size" value to define the size # #使用到的函数1. is_ Uploaded_file is used to determine whether the file was uploaded via Http-host and returns the bool value 2.move_uploaded_file (' Temporary file path ', ' destination file path ') where the temporary file path refers to the $_FILES[PIC][TMP_ The value in name] # #处理多个文件上传是, the array information passed by post is $_files[pic][tmp_name][0] This element is the temporary storage path for the first file is $_files[pic][name][0] This element is the first file with the filename of $_files[pic][error][0] This element which is the first file with an error message is $_files[pic][size][0] This element is the size of the first file and so on, the second file subscript is incremented, The subscript of several documents is added in turn. That is, the location of the original storage element has all become an array, used to hold the same information for other groups # #文件下载只需要一个普通的a链接就可以定义一个下载路径但是不能识别MIME类型的文件, will be opened directly instead of displaying the download, So we have to let a link jump to the Operation page to set header information (' Contebt-type:image/gif ');//Send header information of the specified type (' Content-disposition:attachment; Filename;filename= "Test.gif");//Send file header information, file name and attachment name Header (' content-lenght:3390 ');//send specified file size
Related recommendations:
PHP file upload need to pay attention to what
PHP file Upload class and PHP package of multi-File upload class sharing
php File Upload parsing