CXYGZG
G--Y
2017-09-23 06:57

求大神帮忙,文件上传

  • java-ee

<%!
String sql;
String fileName,fileRealName,fileExt,path,pathsmall_url,pathsmallReal;
int radomNumber=0;
long nowtime;
%>


<%
Date nowTime=new Date();
SimpleDateFormat matter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String addtime=matter.format(nowTime);
int count=0;
mySmartUpload.initialize(pageContext);
//
mySmartUpload.setTotalMaxFileSize(10000000);
//
mySmartUpload.upload();
com.jspsmart.upload.Request getRequest=mySmartUpload.getRequest();
//
String intro = getRequest.getParameter("intro");
long picsize=0;
try{
count=mySmartUpload.getFiles().getCount();
for(int i=0;i<count;i++){
com.jspsmart.upload.File file=mySmartUpload.getFiles().getFile(i);
if(file.isMissing())continue;
radomNumber=(int)(Math.random()*100)+1;
fileRealName=mySmartUpload.getFiles().getFile(i).getFileName();
fileExt=mySmartUpload.getFiles().getFile(i).getFileExt();
path="chapter2/upload/";
nowtime=System.currentTimeMillis();
//
fileName=path+nowtime+"_"+radomNumber+"."+fileExt;
mySmartUpload.getFiles().getFile(i).saveAs(fileName,mySmartUpload.getFiles().getFile(i).SAVEAS_VIRTUAL);
}
out.print("<a href=uploadform.jsp>文件上传成功<br/>文件说明:"+intro+"<br/>继续上传</a>");

}catch(Exception e){
out.print(e.toString());
}
%>
上传一个文件,改为上传三个文件

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答