<body>
<%
SmartUpload smart = new SmartUpload() ;
smart.initialize(pageContext) ; // 初始化上传操作
smart.upload() ; // 上传准备
String name = smart.getRequest().getParameter("uname") ;
smart.save("/upload"); // 文件保存
//IPTimeStamp its = new IPTimeStamp(request.getRemoteAddr()) ;
IPTimeStamp its = new IPTimeStamp("192.168.1.1") ;// 取得客户端的IP地址
String ext = smart.getFiles().getFile(0).getFileExt() ; // 扩展名称
String fileName = its.getIPTimeRand() + "." + ext ;
System.out.print(fileName);
smart.getFiles().getFile(0).saveAs(this.getServletContext().getRealPath("/")+"upload"+java.io.File.separator + fileName) ;
%>
<h2>姓名:<%=name%></h2>
<%=smart.getFiles().getFile(0).getFileName().matches("^\\w+.(jpg|gif)$")%>
<h2>姓名:<%=name%></h2>
<img src="../../../upload/<%=fileName%>">
<%
SmartUpload smart = new SmartUpload() ;
smart.initialize(pageContext) ; // 初始化上传操作
smart.upload() ; // 上传准备
String name = smart.getRequest().getParameter("uname") ;
smart.save("/upload"); // 文件保存
//IPTimeStamp its = new IPTimeStamp(request.getRemoteAddr()) ;
IPTimeStamp its = new IPTimeStamp("192.168.1.1") ;// 取得客户端的IP地址
String ext = smart.getFiles().getFile(0).getFileExt() ; // 扩展名称
String fileName = its.getIPTimeRand() + "." + ext ;
System.out.print(fileName);
smart.getFiles().getFile(0).saveAs(this.getServletContext().getRealPath("/")+"upload"+java.io.File.separator + fileName) ;
%>
<h2>姓名:<%=name%></h2>
<%=smart.getFiles().getFile(0).getFileName().matches("^\\w+.(jpg|gif)$")%>
<h2>姓名:<%=name%></h2>
<img src="../../../upload/<%=fileName%>">
</body>
smart.getFiles().getFile(0).saveAs(this.getServletContext().getRealPath("/")+"upload"+java.io.File.separator + fileName) ;
改成:
// smart.getFiles().getFile(0).saveAs(this.getServletContext().getRealPath("/")+java.io.File.separator+"smartupload"+java.io.File.separator+"upload"+java.io.File.separator+filename);
注意:出次错误也可能是因为你的
IPTimeStamp its = new IPTimeStamp(request.getRemoteAddr()) ;// 取得客户端的IP地址
获取的客户端的IP地址格式不正确