PHP has the ability to accept any RFC-1867 to adapt to file uploads from browsers (including Netscape Navigator 3.0 or later, Microsoft Internet Explorer 3.0 (with patches) or later. This feature allows users to upload text and binary files. Using PHP's identity authentication and file processing functions, you have full control over who can upload files and what can be done by uploaded files.
You can use the following method to create a screen for file upload.
Example 2-3. File Upload form
"_ URL _" points to a php html file. MAX_FILE_SIZE the hidden field must be prior to the file input field, and its value is the maximum acceptable file size. The unit of the value is byte. In the target file, the following variables are used to determine whether the file is successfully uploaded:
$ Userfile: name of the temporary file on the server where the uploaded file is to be stored.
$ Userfile_name: initial file name in the sender system.
$ Userfile_size: the size of the uploaded file in bytes.
$ Userfile_type: multi-purpose Internet Mail extended protocol file, if the browser provides this information. An example is "image/gif ".
Note: The "userfile" section can be changed here. It can take any name as long as the TYPE in the upload form is still "TYPE = file. In the above example, we select its name as "userfile ".
Files are stored in the default temporary directory of the server by default. In the PHP running environment, you can change the environmental variable TMPDIR to change this setting. Use a PutEnv () function when the PHP script is not running.
The PHP script language that accepts uploaded files must implement the logical structure to determine what the uploaded files can do. For example, you can use the "$ file_size" variable to send any file that is too small or too large to try the result. You can use the "$ file_type" variable to send any non-conforming file of the determined type standard. Whatever the logical structure, you need to delete the file in the temporary directory or remove it.
If the file is not renamed or moved, the file will be deleted from the Temporary Folder at the end of the request.
Note that after obtaining the MIME connection type from the client, the "CERN httpd" software seems to be stripped of anything and appear in the initial whiteboard form. In this case, the "CERN httpd" software does not support the file upload feature.