标签:
1.uploadfiy插件封装
/*
参数:uploadID:上传控件ID
url:请求后台url路径
callback:回调函数
*/
uploadfiy({
uploadID: $(‘#btn_upload‘), url: ‘/sys/upload‘, callback: function (data) {
if (data.success) {
//todo:do something....
}
}
});
function uploadfiy(options) {
var settings = { uploadID: ‘‘, url: ‘‘, callback: function () { }, fileTypeExts: ‘*.jpg;*.png;‘, width: 82, height: 34, buttonText: ‘上传‘,swf: ‘/Content/uploadify.swf‘ };
options = options || {};
$.extend(settings, options);
settings.uploadID.uploadify({
uploader: settings.url, // 服务器处理地址
swf: settings.swf,
buttonText: settings.buttonText, //按钮文字
height: settings.height, //按钮高度
width: settings.width, //按钮宽度
fileTypeExts: settings.fileTypeExts, //允许的文件类型
formData: { "imgType": "normal" }, //提交给服务器端的参数
onUploadSuccess: function (file, data, response) { //一个文件上传成功后的响应事件处理
var data = $.parseJSON(data);
if ($.isFunction(settings.callback)) {
settings.callback.call(this, data);
}
}
});
}
标签:
原文地址:http://www.cnblogs.com/chenjz/p/4793436.html