This example in the WAP station project needs to do an AJAX multi-image upload, combined with JS plugin made a, for your reference, the specific content as follows
/* Ajax Upload image */var num = 0; Click Delete Picture function OnDelete (num) {if ($ ("#" +num). attr (' src ')! = "__public__/home/images/jiazai.gif" && $ ("#" + num). attr (' src ')! = "") {if (Confirm ("confirm Delete")) {$ ("#a" +num). Remove (); }else{//}}}$ (function () {$ ("#file0"). Bind ("Change", function () {clickupload (num); }); function Clickupload (num) {var imgobject = document.getElementById (' File0 ');//File Object $ ("#yulan"). Append (""); $ ("#yulan"). Append ("
Delete"); var getimagesrc = GetFullPath (Imgobject); Local Path//instanced Image object var pos = Getimagesrc.lastindexof ("."); var LastName = getimagesrc.substring (pos, getimagesrc.length)//Picture suffix if (lastname!= ". jpg" && lastname!= ". PN G "&& lastname!=". jpeg "&& lastname!= '. gif ') {$ (" #a "+num). Remove (); Alert ("Please select a picture"); }else{ajaxfileupload (num); $ ("#file0"). Unbind ("Change"). Bind ("Change", function () {clickupload (num); }); } num++; } function GetFullPath (obj) {//Gets the full path of the picture if (obj) {if (Window.navigator.userAgent.indexOf ("MSIE") > = 1) {obj.select (); Return Document.selection.createRange (). text; }else if (window.navigator.userAgent.indexOf ("Firefox") >= 1) {if (obj.files) {return obj.files.i TEM (0). Getasdataurl (); } return obj.value; } return obj.value; }} functiOn Ajaxfileupload (num) {$.ajaxfileupload ({url: ' http://xxxx/updateImg '),//server-side request address for file upload Secureuri:false,//Whether a security protocol is required, generally set to false fileelementid: ' FILE0 ',//File upload domain ID dataType: ' JSON ',//return The return value type is generally set to JSON success:function (data)//Server Success Response handler function {var jsontext = data; Console.log (Jsontext); if (jsontext[' status ']==1) {if (jsontext[' info ']!= "") {Console.log (jsontext[' info ']); $ ("#" +num). attr ("src", "__public__//admin/upload/" +jsontext[' info '); var images = $ ("#img"). Val (); if (images!= "") {$ ("#img"). Val (images+ "," +jsontext[' info ']); }else{$ ("#img"). Val (images+ "" +jsontext[' info '); }}}else{$ ("#a" +num). Remove (); Alert ("Image upload failed"); } }, Error:function (data,e)//server response failed processing function {alert (e); } } ) }});
The above is the whole content of this article, I hope that you learn PHP programming help.
The above describes the PHP+AJAX+JS implementation of multi-image upload, including the ajax,php aspects of the content, I hope that the PHP tutorial interested friends to help.