PHP has the ability to accept file uploads from any RFC-1867 compliant browser (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 authentication and file handling functions, you have complete control over who can upload files and what can be done with the uploaded files.
You can create a file upload screen using a method similar to the form below.
Example 2-3. File upload form
Where "_URL_" points to a PHP HTML file. The MAX_FILE_SIZE hidden field must precede the file input field, and its value is the maximum acceptable file size. The unit of this value is bytes. In this target file, the following variables are used to define whether the file is successfully uploaded:
$userfile: The name of the temporary file on the server where the uploaded file will be stored.
$userfile_name: The initial file name in the sender's system.
$userfile_size: The size of the uploaded file in bytes.
$userfile_type: Multipurpose Internet Mail Extensions type file, if the browser provides this information. An example is "image/gif".
Note: The "userfile" part here can be changed. It can have any name as long as the type in the upload form is still "TYPE=file". In the above example, we chose its name as "userfile".
The file will be stored in the default temporary directory of the server by default. In the environment where PHP is running, you can change the environment variable TMPDIR to change this setting. When setting, use a PutEnv() function without the PHP script running.
The PHP script that accepts the uploaded file will implement what logical structure is necessary to determine what can be done with the uploaded file. For example, the user can use the "$file_size" variable to send any file that is either too small or too large to try out the results. You can use the "$file_type" variable to send any file that does not conform to the determined type criteria. Regardless of the logical structure, you need to delete this file in the temporary directory or move it.
If it has not been renamed or moved, the file will be deleted from the temporary folder at the end of the request.
Please note that after obtaining the MIME connection type from the client, the "CERN httpd" software appears to strip away any content and emerge as an initial blank slate. In this case, the "CERN httpd" software will not support the upload file feature.
http://www.bkjia.com/PHPjc/531922.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531922.htmlTechArticlePHP has the ability to accept any RFC-1867 adapted browser (including Netscape Navigator 3.0 or later, Microsoft Internet Explorer 3.0 (with patches) or later)...