JspSmartUpload使用笔记
来源:互联网 发布:环迅网络 编辑:程序博客网 时间:2024/05/22 16:07
SmartUpload使用过程中出现的错误!
1.参数传送时,Form的必须加上以下属性:
enctype=multipart/form-data
2.因为SmartUpload组件已经加载了java.io.* 包,页面再次加载将被覆盖,要使用java.io包的方法无法使用,比如创建文件夹,目前还不知道很好的解决方法!!!
3.使用:
<%@ page import="com.jspsmart.upload.*"%>//加载
<%
SmartUpload mySmartUpload = new SmartUpload();
mySmartUpload.initialize(pageContext);
mySmartUpload.upload();
%>//初始化//上传
<%
final String UpFileType="pdf|doc"; //上传文件类型
final int MaxFileSize=102400; //上传文件大小限制
boolean ERR=false; //错误标志
// 取当前文件
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
//文件效验
// 取得文件并保存
if (!myFile.isMissing())
{
//得到文件扩展名
String FileType=myFile.getFileExt();
FileType=FileType.toLowerCase(); //将扩展名转换成小写
if (UpFileType.indexOf(FileType)==-1)
{
ERR=true;
response.sendRedirect("xwb_error.jsp?err=type");//文件格式不对
}
//得到文件大小
int FileSize=myFile.getSize();
if (ERR==false&&FileSize>MaxFileSize)
{
ERR=true;
response.sendRedirect("xwb_error.jsp?err=size");//文件太大
}
}
else
{
response.sendRedirect("xwb_error.jsp?err=noext");
}//上传文件
String filename="";
filename=myFilegetFileName();
out.println(filename);
try{
if (!myFile.isMissing()){
filename=myFile.getFileName();
java.util.Date date=new java.util.Date();
long time=date.getTime();
String title=String.valueOf(time);
String extn=filename.substring(filename.lastIndexOf('.'),filename.length());
filename=title+extn;
myFile.saveAs("/test/wangzhe/filetest/"+filename);
} //END OF IF
}catch (Exception e)
{
out.println("<b>Wrong selection : </b>" + e.toString());
}
%>
- JspSmartUpload使用笔记
- jspSmartUpload使用
- 使用jspsmartUpload组件之一
- 使用jspSmartUpload上传文件
- jspSmartUpload使用详解
- 使用jspSmartUpload下载文件
- JspSmartUpload使用文档
- jspsmartupload如何使用?
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- jspSmartUpload
- 全面理解COM+
- 模式和框架含义探讨
- jsp的三个属性
- HEHE,终于做了一个WINDOWS应用程序
- 计算机类中文权威及核心期刊
- JspSmartUpload使用笔记
- 有关RS232和RS485接口的问答
- CString 操作指南
- 百度给站长的建站指南
- 腾讯启用新标识:三色轨迹环绕小企鹅
- V4L编程资料总结与课题实现规划
- Be peace
- 我的嵌入式之路--转载
- 最有名的冷笑话