日期:2014-05-17 浏览次数:20872 次
<form action="loadOpt.jsp" enctype="multipart/form-data" method="post">
<input type="file" value="浏览"/>
<input type="submit" value="上传"/>
</form>
<%
SmartUpload su=new SmartUpload();
try{
su.initialize(pageContext);
su.upload();
String p=su.getFiles().getFile(0).getFilePathName();
File f=su.getFiles().getFile(0);
if(!f.isMissing()){
String path1="upload/"+f.getFileName();
f.saveAs(path1,SmartUpload.SAVE_VIRTUAL);
out.println("<script>alert('提交成功');location.href='index.jsp'</script>");
}else
{
out.println("<script>alert('提交失败');location.href='index.jsp'</script>");
}
}catch(Exception e)
{
e.printStackTrace();
}
%>