Thinkphp multi-image Upload

Source: Internet
Author: User
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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.