使用 SmartUpload 在jsp中上传文件
2010-07-07 16:02
239 查看
//***************************************文件上传begin*******************************************//
String loadFlag = (String)request.getParameter("loadFlag");
String uploadpath = "";
String outtext = "";
String title = "";
String keywords = "";
String localtext = "";
if(loadFlag != null && !loadFlag.equals(""))
{
loadFlag = "1";
//获得路径
String localpath = PropertiesReader.getValueOf("/application.sm.properties","sm.knowledge_path");
if(localpath == null) localpath = "";
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddhhmmss");
String localTime = sdf.format(new Date());
// 新建一个SmartUpload对象
SmartUpload su = new SmartUpload();
// 上传初始化
su.initialize(pageContext);
// 上传文件
su.upload();
for (int i=0;i<su.getFiles().getCount();i++)
{
com.jspsmart.upload.File file = su.getFiles().getFile(i);
// 若文件存在则继续
if (!file.isMissing())
{
String theFileName = file.getFileName();
String thisFileName =localTime;
String theExtName = theFileName.substring(theFileName.lastIndexOf(".") + 1, theFileName.length());
outtext = thisFileName + "." + theExtName;
request.setAttribute("outtext",outtext);
file.saveAs(localpath + outtext, su.SAVE_PHYSICAL);
}
}
title = su.getRequest().getParameter("title");
if(title == null)
{
title = "";
}
System.out.println(title);
keywords = su.getRequest().getParameter("keywords");
if(keywords == null )
{
keywords = "";
}
localtext = su.getRequest().getParameter("localtext");
if(localtext == null)
{
localtext = "";
}
localtext = new String(localtext.getBytes());
}else
{
loadFlag = "0";
}
//*********************************************文件上传end************************************************//
String loadFlag = (String)request.getParameter("loadFlag");
String uploadpath = "";
String outtext = "";
String title = "";
String keywords = "";
String localtext = "";
if(loadFlag != null && !loadFlag.equals(""))
{
loadFlag = "1";
//获得路径
String localpath = PropertiesReader.getValueOf("/application.sm.properties","sm.knowledge_path");
if(localpath == null) localpath = "";
SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddhhmmss");
String localTime = sdf.format(new Date());
// 新建一个SmartUpload对象
SmartUpload su = new SmartUpload();
// 上传初始化
su.initialize(pageContext);
// 上传文件
su.upload();
for (int i=0;i<su.getFiles().getCount();i++)
{
com.jspsmart.upload.File file = su.getFiles().getFile(i);
// 若文件存在则继续
if (!file.isMissing())
{
String theFileName = file.getFileName();
String thisFileName =localTime;
String theExtName = theFileName.substring(theFileName.lastIndexOf(".") + 1, theFileName.length());
outtext = thisFileName + "." + theExtName;
request.setAttribute("outtext",outtext);
file.saveAs(localpath + outtext, su.SAVE_PHYSICAL);
}
}
title = su.getRequest().getParameter("title");
if(title == null)
{
title = "";
}
System.out.println(title);
keywords = su.getRequest().getParameter("keywords");
if(keywords == null )
{
keywords = "";
}
localtext = su.getRequest().getParameter("localtext");
if(localtext == null)
{
localtext = "";
}
localtext = new String(localtext.getBytes());
}else
{
loadFlag = "0";
}
//*********************************************文件上传end************************************************//
相关文章推荐
- JSP使用SmartUpload实现文件上传
- JSP使用SmartUpload实现文件上传
- 【转载】使用jsp实现文件上传到服务器或者从服务器上下载文件到本地计算机完整说明版
- 【转】在jsp中使用smartupload组件上传文件
- JSP+Servlet使用jspsmartupload实现文件上传至服务器
- 使用smartupload完成JSP中图片上传存储
- 在jsp中使用smartupload组件上传文件
- 在jsp中使用smartupload组件上传文件
- jsp+servlet实现文件上传(不使用任何组件和框架)
- 使用jspsmartupload解决enctype引起的无法同时上传文件和接值的问题
- JSP使用上传文件,并生产高清缩略图示例
- 项目开发技巧(四):使用JspSmartupload实现文件上传下载(二):jspSmartUpload上传下载全攻略(ZZ)
- 使用smartUpload组件进行文件上传以及获取文本数据
- 在jsp中使用smartupload组件上传文件
- 使用jspSmartUpload组件进行文件上传、下载
- 【Jsp】使用jspsmartupload完成简单的文件上传系统
- 在jsp中使用smartupload组件上传文件
- jsp中使用第三方组件实现文件上传
- 使用jsp上传文件
- Jsp 使用commons-fileupload实现文件上传