Multiple File upload operations based on Ajaxupload, ajaxupload File Upload
If you don't talk much about it, paste the Code directly. The specific code is as follows:
<Pre name = "code" class = "php"> <? Php $ ele = $ _ GET ['ele ']; $ file = $ _ FILES ['thumb _'. $ ele]; $ pathinfo = pathinfo ($ file ['name']); $ filedir = 'uploads /'. date ('y'); if (! Is_dir ($ filedir) {mkdir ($ filedir) ;}$ filedir. = '/'. date ('md'); if (! Is_dir ($ filedir) {mkdir ($ filedir);} $ filedir. = '/'. time (). '_'. mt_rand (1000,999 9 ). '. '. $ pathinfo ['extension']; $ msg = ''; if (! Move_uploaded_file ($ file ['tmp _ name'], $ filedir) {$ msg = 'upload failed';} $ data = array ('msg '=> $ msg, 'filedir' => $ filedir); sleep (2); echo json_encode ($ data);?> </Pre> <br> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head> <meta http-equiv =" Content-Type "content =" text/html; charset = gbk "/> <title> Ajax upload </title> <script src =" jquery-1.4.4.min.js "type =" text/javascript "> </script> <script src =" ajaxfileupload. js "type =" text/javascript "> </script> <script type =" text/javascript "> function fileupload (ele) {$ (" # loading "). ajaxStart (function () {jQuery ("# photoImg "). hide (); jQuery (this ). show ();}). ajaxComplete (function () {jQuery (This). hide (); jQuery ("# photoImg"). show () ;}); $. ajaxFileUpload ({url: "index. php? Ele = "+ ele, secureuri: false, fileElementId:" thumb _ "+ ele, dataType:" json ", success: function (data, status) {if (data. msg! = '') {Alert (data. msg);} else {$ ("[name = 'photo _" + ele + "']"). val (data. filedir); $ ("# photoImg _" + ele ). attr ("src", data. filedir) ;}, error: function (data, status, e) {alert (e) ;}}) return false ;} </script>
Summary
The above is a multi-file upload operation based on Ajaxupload introduced by xiaobian. I hope it will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!