The example in this article describes the implementation method of multi-file upload in Thinkphp and is shared with everyone for your reference. The specific implementation method is as follows:
The Thinkphp manual describes clearly how to upload multiple files: If you need to use multiple files, you only need to modify the form and add
Copy code The code is as follows:
Change to
Copy code The code is as follows:
or
Copy code The code is as follows:
li>
For now, you have two upload form fields, one for uploading pictures and one for uploading videos. The field names are image and video.
The html code is as follows
At the end of the article, let me analyze the principle of multi-file upload. Let’s take a look at the html code first
Copy code The code is as follows:
li>
This is to define the form variable as an array. In PHP, the array special variable can store multiple content of variable length, so we can customize the multi-file upload box. So how do we operate when processing in PHP? Let’s see below example.
Copy code The code is as follows:
protected $_auto = array(
array('image','upload',3,callback),//Autocomplete method
array('video','videoupload',3,callback), //Autocomplete method
);//Automatically fill in uploaded images to generate thumbnails
This tells thinkphp that it is an array variable. There is no need to judge the length of the traversed array and upload the code one by one like in the original PHP, because thinkphp has already done it.
I hope this article will be helpful to everyone’s ThinkPHP framework programming.
http://www.bkjia.com/PHPjc/904017.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/904017.htmlTechArticleThinkphp multi-file upload implementation method. This article describes the Thinkphp multi-file upload implementation method and shares it with you for your reference. . The specific implementation method is as follows: In the Thinkphp manual, for...
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn