Spring MVC uploadify21批量文件图片上传文档格式.docx

上传人:b****5 文档编号:8422391 上传时间:2023-05-11 格式:DOCX 页数:14 大小:16.66KB
下载 相关 举报
Spring MVC uploadify21批量文件图片上传文档格式.docx_第1页
第1页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第2页
第2页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第3页
第3页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第4页
第4页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第5页
第5页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第6页
第6页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第7页
第7页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第8页
第8页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第9页
第9页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第10页
第10页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第11页
第11页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第12页
第12页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第13页
第13页 / 共14页
Spring MVC uploadify21批量文件图片上传文档格式.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Spring MVC uploadify21批量文件图片上传文档格式.docx

《Spring MVC uploadify21批量文件图片上传文档格式.docx》由会员分享,可在线阅读,更多相关《Spring MVC uploadify21批量文件图片上传文档格式.docx(14页珍藏版)》请在冰点文库上搜索。

Spring MVC uploadify21批量文件图片上传文档格式.docx

  [javascript]viewplaincopyprint?

  $(document).ready(function(){

  $("

#multiple_file_upload"

).uploadify({

  '

uploader'

:

'

${base}/thirdparty/uploadify/uploadify.swf?

random='

+(newDate()).getTime(),

cancelImg'

${base}/thirdparty/uploadify/cancel.png'

script'

../common/o_multiple_upload.do'

//要提交到的处理文件上传的PHP文件

auto'

false,//是否自动开始

multi'

true,//是否支持多文件上传

buttonText'

'

browe'

//按钮上的文字

simUploadLimit'

1000,//一次同步上传的文件数目

sizeLimit'

19871202,//设置单个文件大小限制

queueSizeLimit'

1000,//队列中同时存在的文件个数限制

fileDesc'

支持格式:

jpg/gif/jpeg/png/bmp.'

//如果配置了以下的'

fileExt'

属性,那么这个属性是必须的

*.jpg;

*.gif;

*.jpeg;

*.png;

*.bmp'

//允许的格式

  onComplete:

function(event,queueID,fileObj,response,data){

  //$('

).appendTo('

.files'

).text(response);

  varpicIndexPlus=picIndex++;

  varuploadPath=response;

  $('

#picBefore'

).before(picTpl(picIndexPlus));

  varuploadImgPathId="

uploadImgPath"

+(picIndexPlus);

  document.getElementById(uploadImgPathId).value=uploadPath;

  },

  onError:

function(event,queueID,fileObj){

  alert("

文件:

"

+fileObj.name+"

上传失败"

);

  onCancel:

function(event,queueID,fileObj){

  //alert("

取消了"

+fileObj.name);

  }

  });

5、后台代码Java代码

  [java]viewplaincopyprint?

  /**

  *批量上传图片

  *

  *@paramfilename文件名

  *@paramuploadNum上传数量

  *@parammark

  *@paramfile文件流

  *@paramrequest

  *@parammodel

  *@return

  *@throwsException

  */

  @RequestMapping(value="

/common/o_multiple_upload.do"

  public@ResponseBody

  StringexecuteMultiple(Stringfilename,IntegeruploadNum,Booleanmark,HttpServletRequestrequest,

  HttpServletResponseresponse,ModelMapmodel)throwsException

  {

  MultipartHttpServletRequestmultipartRequest=(MultipartHttpServletRequest)request;

  MapfileMap=multipartRequest.getFileMap();

  //存储fileUrl

  ListuploadPaths=newArrayList();

  StringfileUrl=null;

  for(Map.Entryentity:

fileMap.entrySet())

  //获取MulipartFile对象

  MultipartFilefile=entity.getValue();

  WebErrorserrors=validate(filename,file,request);

  if(errors.hasErrors())

  model.addAttribute(ERROR,errors.getErrors().get(0));

  returnRESULT_PAGE;

  CmsSitesite=CmsUtils.getSite(request);

  MarkConfigconf=site.getConfig().getMarkConfig();

  if(mark==null)

  mark=conf.getOn();

  //上传文件名

  StringorigName=file.getOriginalFilename();

  Stringext=FilenameUtils.getExtension(origName).toLowerCase(Locale.ENGLISH);

  try

  if(site.getConfig().getUploadToDb())

  StringdbFilePath=site.getConfig().getDbFileUri();

  if(!

StringUtils.isBlank(filename))

  filename=filename.substring(dbFilePath.length());

  if(mark)

  FiletempFile=mark(file,conf);

  fileUrl=dbFileMng.storeByFilename(filename,newFileInputStream(tempFile));

  tempFile.delete();

  else

  fileUrl=dbFileMng.storeByFilename(filename,file.getInputStream());

  fileUrl=dbFileMng.storeByExt(site.getUploadPath(),ext,newFileInputStream(tempFile));

  fileUrl=dbFileMng.storeByExt(site.getUploadPath(),ext,file.getInputStream());

  //加上访问地址

  fileUrl=request.getContextPath()+dbFilePath+fileUrl;

  elseif(site.getUploadFtp()!

=null)

  Ftpftp=site.getUploadFtp();

  StringftpUrl=ftp.getUrl();

  filename=filename.substring(ftpUrl.length());

  fileUrl=ftp.storeByFilename(filename,newFileInputStream(tempFile));

  fileUrl=ftp.storeByFilename(filename,file.getInputStream());

  fileUrl=ftp.storeByExt(site.getUploadPath(),ext,newFileInputStream(tempFile));

  fileUrl=ftp.storeByExt(site.getUploadPath(),ext,file.getInputStream());

  //加上url前缀

  fileUrl=ftpUrl+fileUrl;

  Stringctx=request.getContextPath();

  filename=filename.substring(ctx.length());

  fileUrl=fileRepository.storeByFilename(filename,tempFile);

  fileUrl=fileRepository.storeByFilename(filename,file);

  fileUrl=fileRepository.storeByExt(site.getUploadPath(),ext,tempFile);

  fileUrl=fileRepository.storeByExt(site.getUploadPath(),ext,file);

//加上部署路径

  fileUrl=ctx+fileUrl;

  fileMng.saveFileByPath(fileUrl,origName,false);

  uploadPaths.add(fileUrl);

  model.addAttribute("

uploadNum"

uploadNum);

  catch(IllegalStateExceptione)

  model.addAttribute(ERROR,e.getMessage());

  log.error("

uploadfileerror!

e);

  catch(IOExceptione)

  catch(Exceptione)

  //model.addAttribute("

uploadPaths"

uploadPaths);

  returnfileUrl;

StringUti

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2