This article example in the WAP station project needs to do an AJAX multiple image upload, combined with JS plug-in to do a, for everyone's reference, the specific content as follows
/* Ajax Upload Picture * * var num = 0; Click Delete Picture function OnDelete (num) {if ($ ("#" +num). attr (' src ')!= "__public__/home/images/jiazai.gif" && $ ("#" +
num). attr (' src ')!= "") {if (Confirm ("Confirm deletion")) {$ ("#a" +num). Remove (); }else{//}} $ (function () {$ ("#file0"). Bind ("Change", function () {Clickupload (nu
m);
}); function Clickupload (num) {var imgobject = document.getElementById (' File0 ');//File Object $ ("#yulan"). Append ("&l T;a id= ' A "+num+" ' onclick= ' OnDelete ("+num+") ' href= ' javascript:; '
> </a> '); $ ("#yulan"). Append ("<li id= ' a" +num+ "' > Delete </a></li> '); var getimagesrc = GetFullPath (Imgobject); Local path//materialized Image object var pos = GetImageSrc.lastindexof ("."); var LastName = getimagesrc.substring (pos, getimagesrc.length)//Picture suffix if (lastname!= ". jpg" && lastname!= ".
PNG "&& 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) {//Get 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
. Item (0). Getasdataurl ();
return obj.value;
return obj.value;
}} function Ajaxfileupload (num) {$.ajaxfileupload ({ URL: ' http://xxxx/updateImg ',//For file Upload server-side request address secureuri:false,//Whether security protocol is required, generally set to false fileelement
ID: ' FILE0 ',//File upload domain ID dataType: ' JSON ',//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 ("Picture upload failed");
}}, Error:function (data,e)//server response failed handler function {alert (e); }
}
)
}
});
The above is the entire content of this article, I hope that you learn PHP program help.