87,899
社区成员
发帖
与我相关
我的任务
分享
$(document).ready(function () {
$('#file_upload').uploadify({
'swf': '/js/uploadify/uploadify.swf', //不多讲了
'uploader': '/Member/ascx/uploadImg.ashx', //处理Action
'queueSizeLimit': '4', //每次能上传文件数量
'uploadLimit': '4', //最多上传文件数量
'queueID': 'queueID', //显示上传文件队列的元素id,可以简单用一个div显示
'fileSizeLimit': '1024', //上传文件大小限制
'fileTypeExts': '*.jpg', //上传文件格式限制
'buttonText': '选择图片', //按钮显示文字
//'buttonImage':'图片路径',//通过设置背景图片解决中文问题,就是把背景图做成按钮的样子
'multi': 'true', //多文件上传开关
'auto': 'false',
'removeCompleted':'false',
onUploadSuccess: function (file, data, response) {
var rr = null
rr = eval("(" + data + ")");
if (rr.Result == "true") {
//alert(rr.Url); //只要使用alert,返回值就全部正确了,这个问题怎么解决?
$("#listPic").val(rr.Url + "," + $("#listPic").val());
$('#queuelist').append("<img src='" + rr.Url + "' alt='' width='225' height='160' style='float:left;margin:0px 0px 5px 5px;'>");
//alert('The file ' + file.name + ' was successfully uploaded with a response of ' + response + ':' + data);
}
}
});
});
// Triggered when a file upload returns a successful code
onUploadSuccess : function(file, data, response) {
// Load the swfupload settings
var settings = this.settings;
var stats = this.getStats();
this.queueData.uploadsSuccessful = stats.successful_uploads;
this.queueData.queueBytesUploaded += file.size;
// Call the default event handler
if ($.inArray('onUploadSuccess', settings.overrideEvents) < 0) {
$('#' + file.id).find('.data').html(' - Complete');
}
// Call the user-defined event handler
if (settings.onUploadSuccess) settings.onUploadSuccess.call(this, file, data, response);
}
$("#listPic").val(rr.Url + "," + $("#listPic").val());
$('#queuelist').append("<img src='" + rr.Url + "' alt='' width='225' height='160' style='float:left;margin:0px 0px 5px 5px;'>");
因为alert影响用户体验,我就注释掉了,然后就一直返回批量文件中的其中一个相同值。
onUploadSuccess 这个事件是每次上传一个文件成功,就响应一次。alert(rr.Url);//
console.log(rr.Url)
img都是一样?onUploadSuccess: function (file, data, response) {
console.log(data)
}
改成这样,看看控制台都返回的是什么,再数一下是不是打印出了4行信息。
然后再慢慢定位吧。。