mirror of
				https://gitee.com/zoujingli/ThinkAdmin.git
				synced 2025-10-27 02:12:08 +08:00 
			
		
		
		
	Update upload.js
This commit is contained in:
		
							parent
							
								
									b967dd6a6a
								
							
						
					
					
						commit
						e40021021a
					
				| @ -3,9 +3,10 @@ define(['md5'], function (SparkMD5, allowExtsMimes) { | |||||||
|     return function (element, InitHandler, UploadedHandler) { |     return function (element, InitHandler, UploadedHandler) { | ||||||
|         /*! 定义初始化变量 */ |         /*! 定义初始化变量 */ | ||||||
|         var exts = [], mimes = [], safe, field, uptype, multiple, types, $input, index; |         var exts = [], mimes = [], safe, field, uptype, multiple, types, $input, index; | ||||||
|         safe = $(element).attr('data-safe') || '', field = $(element).data('field') || 'file'; |         safe = $(element).attr('data-safe') || ''; | ||||||
|         types = ($(element).data('type') || '').split(','), $input = $('[name="' + field + '"]'); |         uptype = safe ? 'local' : $(element).attr('data-uptype') || ''; | ||||||
|         uptype = $(element).attr('data-uptype') || '', multiple = $(element).attr('data-multiple') > 0; |         field = $(element).data('field') || 'file', $input = $('[name="' + field + '"]'); | ||||||
|  |         types = ($(element).data('type') || '').split(','), multiple = $(element).attr('data-multiple') > 0; | ||||||
|         /*! 设置文件选择筛选规则 */ |         /*! 设置文件选择筛选规则 */ | ||||||
|         for (index in types) if (allowExtsMimes[types[index]]) { |         for (index in types) if (allowExtsMimes[types[index]]) { | ||||||
|             mimes.push(allowExtsMimes[types[index]]), exts.push(types[index]); |             mimes.push(allowExtsMimes[types[index]]), exts.push(types[index]); | ||||||
| @ -22,13 +23,14 @@ define(['md5'], function (SparkMD5, allowExtsMimes) { | |||||||
|                     files = object.pushFile(), $input.data('files', files); |                     files = object.pushFile(), $input.data('files', files); | ||||||
|                     for (index in files) md5file(files[index]).then(function (file) { |                     for (index in files) md5file(files[index]).then(function (file) { | ||||||
|                         $input.data('file', file).data('index', index); |                         $input.data('file', file).data('index', index); | ||||||
|                         jQuery.ajax("{:url('@admin/api.upload/state',[],false)}", { |                         jQuery.ajax("{:url('@admin/api.upload/state')}", { | ||||||
|                             data: {xkey: file.xkey, uptype: uptype, safe: safe}, method: 'post', success: function (ret) { |                             data: {xkey: file.xkey, uptype: uptype, safe: safe}, method: 'post', success: function (ret) { | ||||||
|                                 file.xurl = ret.data.url; |                                 file.xurl = ret.data.url; | ||||||
|                                 if (ret.code === 404) { |                                 if (ret.code === 404) { | ||||||
|                                     uploader.config.data.safe = safe; |                                     uploader.config.data.safe = safe; | ||||||
|                                     uploader.config.url = ret.data.server; |                                     uploader.config.url = ret.data.server; | ||||||
|                                     uploader.config.data.key = ret.data.xkey; |                                     uploader.config.data.key = ret.data.xkey; | ||||||
|  |                                     uploader.config.data.uptype = ret.data.uptype; | ||||||
|                                     if (ret.data.uptype === 'qiniu') { |                                     if (ret.data.uptype === 'qiniu') { | ||||||
|                                         uploader.config.data.token = ret.data.token; |                                         uploader.config.data.token = ret.data.token; | ||||||
|                                     } |                                     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user