/** * Created by Administrator on 2018-05-05. *//*var obj={ pickId:{id:"#filePicker"}, serverUrl :"/itsm/a/file/upload", sid :"555555",}*/function webUpload(obj,fn) { var width=100; var height=85; var uploader = WebUploader.create({ swf: './js/Uploader.swf', server: "//a/fie/upoad", pick: {id:obj.pickId}, }); uploader.on('fileQueued', function (file) { uploader.md5File(file) .progress(function (percentage) { console.log('Percentage:', percentage); }) .then(function (val) { uploader.options.formData.fileMd5 = val; uploader.options.formData.fileName = file.name; uploader.options.formData.__sid = getQueryParam('sessionid'); uploader.options.formData.uploadType="all"; uploader.options.formData.bizType=obj.bizType; uploader.options.formData.bizKey=obj.bizKey; console.log(" uploader.options.formData:", uploader.options.formData); uploader.upload() }); uploader.makeThumb(file, function (error, src) { if (error) { console.log("不能預覽") return; } var img=new Image(); img.width=width; img.height=height; img.src=src $(obj.pickId+" .webuploader-pick").html(img); }, width, height); }); uploader.on('uploadSuccess', function (file,response ) { $(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-success") console.log("上傳成功返回值:",JSON.stringify(response)) fn.call(null,response) }); uploader.on('uploadError', function (file) { $(obj.pickId+" .webuploader-pick").addClass("webuploader-pick-error") console.log("上傳失敗") });}