In order for the client user to be able to upload the file, we must provide a form in the user interface to submit a request to upload the file. Since the uploaded file is a special kind of data, different from other post data, we must set a special code for the form
<form enctype= "Multipart/form-data" method= "POST" action= "upload.php" ></form>
Above the enctype attribute, you may not be familiar with it, as this is often ignored. However, if the HTTP POST request has both regular data and file class data, this property should be displayed plus, which can improve compatibility for various browsers
Next, we need to add a field to the form for uploading the file:
<input name= "Attachment" type= "file" >
To better illustrate how to handle file uploads, give a complete example
<p> please upload your attachment:</p>
<form enctype= "Multipart/form-data" method= "POST" action= "upload.php" >
<input name= "Attachment" type= "file" >
<input value= "Upload Attachment" type= "Submit" >
</form>
Tip: You can set the maximum number of files allowed to be uploaded by Upload_max_filesize in php.ini. In addition, there is a post_max_size can also be used to set the maximum allowed to upload the form data, in particular, the form of the sum of the various data, so you can also set this field to control the maximum number of uploaded files. However, note that the value of the latter must be greater than the former, because the former belongs to the latter part of the form data
</div>
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.