One, the common place of life:
A) such as mailbox, space, library, Baidu Cloud, micro-love and other places, can see the file upload and download the application, therefore, upload and download the function is very important!
Second, file upload and download in PHP
a) We need to make some settings to make our form have the ability to submit files!
B) Client settings:
I is actually the form's settings:
1.input The type attribute value in the form item must be a file type
2.form form header need to add a pass: enctype= "multipart/ Form-data ", meaning to let the server realize that we want to upload files in this form!
3. The upload method must be post, otherwise it cannot be uploaded
Ii. in the PHP script to obtain the way to upload the file information:
1.$_files can get the file information stored in the array
C) server-side settings:
I. is used to filter the user uploaded files, not all files users can submit to the server, must pass the PHP script processing, before you can submit! Search File_uploads in php.ini
1. Open the button that allows the file to be submitted: "php.ini" file_uploads = on
2. Temporary storage directory for files uploaded to the server:
Uplo Ad_tmp_dir = "D:/wamp/tmp"
3. Maximum size of files allowed to be uploaded by the server:
Upload_max_filesize = 2M
4. Maximum number of files that the server allows to upload:
Max_file_uploads =
5. Maximum upload data size allowed by the form:
Post_max_size = 8M
D) data format of the uploaded file:
I. Pic: Represents the name of the input form item in the form form
II. Name: filename of the file
III. type: Types of files
Iv. tmp_name: File name for temporary storage
V. Error: 0,1,2,3,4,6,7, no error number represents a situation that is encountered in an upload
1.0: Indicates no error has occurred
2.1: Indicates that the size of the uploaded file exceeds the agreed value.
3.2: Indicates that the upload file size exceeds the maximum value specified by the Max_file_size element of the HTML form hidden field property
4.3: Indicates that the file is only partially uploaded
5.4: not uploading any files
6.6: Indicates that the temporary folder cannot be found.
7.7: File Write failure
Vi. Size: Sizes of uploaded files
e) functions for file uploads:
I.move_uploaded_file (temporary file name, new filename "with path"), move temporary files to the specified directory
Ii. Is_uploaded_file (temporary file name): Determine if temporary files are not a valid upload file
Uploading and downloading of "PHP" files