<tr> <td></td> <td colspan="2"><img id="SF_USERS_DEF1" src="${sfroot}/images/pic_man.jpg" class="sf_img" /> <input id="SF_USERS_PHOTO" name="PHOTO" type="hidden" value="/simages/pic_man.jpg" /></td> </tr> <tr> <td>文件上传</td> <td colspan="2"> <!-- conf: 标签配置信息 swfPath:开源插件路径 uploadUrl:接收附件上传请求的视图控制器路径 autoRemoveWhenError:发生异常时自动移除上传的附件 autoRemoveWhenComplete:上传完成后是否自动移除附件 onUploadComplete:上传完成后的回调函数 btnImg:上传按钮的背景图片 fileSize:附件大小的最大值 btnText:上传按钮的文本 fileTypes:可上传的附件的后缀名 --> <div id="sf_file" sf_type="SF_FileUpload" conf='{ swfPath:"${sfroot}/sf_js/openSource/swfupload/swfupload.swf", uploadUrl:"${sfroot}/system/file/upload.do", autoRemoveWhenError:true, autoRemoveWhenComplete:false, onUploadComplete:M_Sf_js_api.onUploadComplete, btnImg:"", fileSize:"10 MB", btnText:"选择文件", fileTypes:"*.jpg;*.jpeg;*.gif;*.png;*.tiff;*.bmp;*.doc;*.txt;*.rar;*.zip;*.xlsx;*.xls;*.pdf"}'> </div> </td> </tr>
/** * 跳转至文件上传页面 * @param * @return * @author yzp * @history 2018-5-3 下午5:17:52 Create by 【yzp】 */ @RequestMapping("toFileupload.do") public ModelAndView toFileupload(HttpServletRequest request,HttpServletResponse response, ModelMap modelMap) { return new ModelAndView( this.getActionPath("fileupload"), modelMap ); }
M_Sf_js_api.onUploadComplete = function(sender, data) { var url = data.rootDirectory + "/" + data.parentPath + "/" + data.newName + "." + data.extension; $("#SF_USERS_DEF1").attr("src", SF_Path.getContextPath() + "/" + url); $("#SF_USERS_PHOTO").val(url); };