利用smartupload写的一个上传页面

<%@ page contentType="text/html" pageEncoding="GBK"%>
<%@ page import="java.smart.*"%>
<%@ page import="java.util.*"%>
<html>
<head><title>www.xiongsheng.com, 熊胜的主页</title></head>
<body>
<%
request.setCharacterEncoding("GBK");
%>
<%
SmartUpload smart = new SmartUpload();
smart.initialize(pageContext);
smart.upload();
String name = smart.getRequest().getParameter("uname");
IPTimeStamp its = new IPTimeStamp(request.getRemoteAddr());
String ext = smart.getFiles().getFile(0).getFileExt();
String fileName = its.getIPTimeRand() + "." + ext;
smart.getFiles().getFile(0).saveAs(this.getServletContext().getRealPath("/")+"upload"+java.io.File.separator + fileName);
%>
<%=smart.getFiles().getFile(0).getFileName().matches("^\\w+.(jpg|gif)$")%>
<h2>姓名:<%=name%></h2>
<img src="../upload/<%=fileName%>">
</body>
</html>

你可能感兴趣的:(利用smartupload写的一个上传页面)