Home > php教程 > php手册 > Upload multiple files in one step

Upload multiple files in one step

WBOY
Release: 2016-09-20 03:30:10
Original
1086 people have browsed it

The template page uses an upload function written by jquery ajax, and calls the upload class provided by thinkphp.
Here I will provide you with an idea. After all, I am not a very good person, and some places may be unreasonable. I hope you can be good at it. After reading it, I can optimize the code. In short, I achieved what I wanted to do,
The projects I have developed here shall prevail:
1. First create a new method and introduce the class
Upload multiple files in one step
This class handles uploaded files
2. Write your own front-end page on the template page, and create different pages according to your own project. I will briefly mention it here
Upload multiple files in one step
You can see that the upload has been successful here. If you are not sure, you can check the uploaded directory
Upload multiple files in one step
Enter the directory of files that have been uploaded, then the next step is to write to the database
Because it is a template file written by jquery ajax, the name values ​​​​are all the same. We can see it in the browser debugging mode
Upload multiple files in one step
Create a new form processing method to process these contents
Because the name values ​​of the files we submit are all the same, when you print and view, only the last submitted file will be displayed. We use this to get the file_get_contents("php://input");post value,

Upload multiple files in one step
Then process its format to make it an arrayarray(5) {<br> [0] => string(60) "/Uploads/vod/2016-09-19/1a5b6a425298469c7d9a9e7a46985787.mp3"<br> [1] => string(60) "/Uploads/vod/2016-09-19/21541962b9f22fc2d120c13ddee2490f.mp3"<br> [2] => string(60) "/Uploads/vod/2016-09-19/1a3c11d2def2a7b6d3a58859560885b2.mp3"<br> [3] => string(60) "/Uploads/vod/2016-09-19/dcde4d039151281685f34cf0dfb8499d.mp3"<br> [4] => string(60) "/Uploads/vod/2016-09-19/612f20f2a5b4bd79d437b71f49ec2a9d.mp3"<br> }Finally$countarray=count($mp);<br>                                                                                                                                                                                                                                                                                  to process. for($k=0;$k<=$countarray;$k++){<br />               $section=M('section');<br />               $data=array();<br /> $ Data ['name'] = No. $ k. Collection; <br />              $data['url'] = $mp[$k];<br />              $data['time'] = time();<br />              $data['uid'] = $this->memberinfo['userid'];<br>              $data['vid'] = $_GET['vod_id'];<br>                     $section->add($data);<br>In this case, it will be updated directly to the database

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template