上代码:
js
$.ajaxFileUpload({
url:'OTISUA030_UPF',
secureuri:false,
fileElementId:obj.id,
dataType: 'json',
success: function (json) {
if(json.message != "") {
$("#"+messageId).append(json.message);
return false;
}
var path = json.path;
var fileName = "";
if(json.imageFileNameOfCertificate1 == null) {
fileName = json.imageFileNameOfCertificate2;
}
else{
fileName = json.imageFileNameOfCertificate1;
}
var imgStr = "<img width='50px' height='50px' src='show.jsp?pid="+fileName+"' onclick='Action(\""+imageFileNameOfCertificateId+"\")' style='cursor:pointer'/>";
imgStr += "<img src='common/images/deleteImg.png' height='20px' onclick=\"deleteFile('"+showId+"','"+fileName+"','"+imageFileNameOfCertificateId+"')\"/>";
$("#"+showId).append(imgStr);
$("#"+imageFileNameOfCertificateId).attr("value",fileName);
$("#"+imgStrView).attr("value",imgStr);
},
error: function (json) {
alert(json);
}
});
ajaxfileupload 端
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
if(window.ActiveXObject) {
if(jQuery.browser.version=="9.0") {
iframeHtml = document.createElement('iframe');
iframeHtml.id = frameId;
iframeHtml.name = frameId;
} else if(jQuery.browser.version=="6.0"||jQuery.browser.version=="7.0"||jQuery.browser.version=="8.0") {
//var iframeHtml = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
if(typeof uri== 'boolean'){
iframeHtml += ' src="' + 'javascript:false' + '"';
}
else if(typeof uri== 'string'){