QFSUpload.js 977 Bytes
(function($) {       
	$.fn.QFSUpload = function(options) {
	var defaults = {
		'height':50,
		'width':50,
		'swf':'http://static.yohobuy.com/js/uploadify/uploadify.swf',
		'buttonImage':'/res/images/add.png',
		'method':'post',
		'uploader':'http://upload.static.yohobuy.com',
		'formData':{ 'project': 'goodsimg' },
		'scriptAccess':'always',
		'file_post_name':'fileData',
		'multi':false,
		'queueID':'images_upload',
		'onSuccess':'',
		'file_queue_limit' : 0
	};
	var params = $.extend(defaults, options);
	return this.each(function() {
			params['onUploadSuccess'] = function(file, data, response){
				var _data = eval("(" + data + ")");
				if (_data.code != 200) {alert(_data.message);return;}
				if (_data.data.imagesList.length < 1) {alert('上传失败.');return;}
				if(params.onSuccess == ''){return _data.data.imagesList[0];}
				eval(params.onSuccess(_data.data.imagesList[0],this.wrapper.selector));
			};
			$(this).uploadify(params);
		});
	};
})(jQuery);