Thinkphp multi-image Upload
$ Upload = new \ Think \ Upload (); // instantiate the upload class $ upload-> maxSize = 3145728; // Set the attachment upload size $ upload-> exts = array ('jpg ', 'GIF', 'PNG', 'jpeg '); // Set the attachment upload type $ upload-> savePath = '1/'; // Set the attachment upload Directory // upload file $ info = $ upload-> upload (); trace ($ info, "all uploaded file arrays"); if (! $ Info) {// upload error message $ this-> error ($ upload-> getError ());} else {// Upload successful $ this-> success ('upload successful! ', U ('index/index1'); foreach ($ info as $ file) {$ urls =. '/Uploads /'. $ file ['savepath']. $ file ['savename']; array_push ($ urlss, $ urls );}}
Why trace ($ info, "all uploaded file arrays"); only one array is obtained... Please help me
Reply to discussion (solution)
Upload multiple files
We recommend that you do this: create a separate table for the attachment for storage. If an attachment is not successfully uploaded, write a record to the table, and add an attachment record to js, when multiple attachments are uploaded, they are selected multiple times. The probability of such errors is much lower.
Print_r ($ info); check it out.
$ Info only saves the information of the uploaded files.
Check whether $ info = $ upload-> upload (); multi-file upload is supported...
Try