Php allows you to upload images in batches,

Source: Internet
Author: User

Php allows you to upload images in batches,

This example describes how php can upload images in batches. We will share this with you for your reference. The details are as follows:

<? Phpfunction upload_multi ($ path, $ photo, $ I) {$ uploaddir = './'. $ path; // file storage directory if (! File_exists ($ uploaddir) // If the directory does not exist, create $ uploaddir = mkdir ($ uploaddir); $ piece = explode ('. ', $ photo ['name'] [$ I]); $ uploadfile = $ uploaddir. '/'. md5 ($ piece [0]). '. '. $ piece [1]; $ result = move_uploaded_file ($ photo ['tmp _ name'] [$ I], $ uploadfile); if (! $ Result) {exit ('upload failed');} return basename ($ uploadfile);} if ($ _ POST ['tijiao']) {extract ($ _ POST ); $ I = 0; foreach ($ _ FILES ["pictures"] ["error"] as $ key => $ error) {if ($ error = UPLOAD_ERR_ OK) {upload_multi ($ email, $ _ FILES ["pictures"], $ I) ;}$ I ++ ;}}?> <Script language = "javascript"> function go_up () {document. getElementById ('new _ up '). innerHTML + = '<input type = "file" name = "pictures []"/> <br>' ;}</script> <form action = "index. php "method =" post "enctype =" multipart/form-data "> <p> multi-Image Upload </p> <br> <input type =" file "name =" pictures [] "/> <br> <div id =" new_up "> </div> <input type =" button "" name = "add_img" value = "add upload" onclick = "go_up () "/> <br> <input type =" submit "value =" Send "name =" tijiao "/> <br> </form>

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.