日期:2014-05-16 浏览次数:20461 次
<%@ page language="java" pageEncoding="UTF-8"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>上传图片</title> <script type="text/javascript" src="scripts/jquery.js"></script> <link href="styles/default.css" rel="stylesheet" type="text/css" /> </head> <script type="text/javascript"> function comm(){ var spell = document.form1.spell.value; document.form1.action="flowManage.m?m=doupload&spell="+spell; document.form1.submit(); } </script> <body> <form action="" name="form1" method="post" enctype="multipart/form-data"> <input type="hidden" name="spell" value="${officelocation.spell}"/> <table width="75%" border="1" align="center"> <tr> <td> <div align="center"> <input type="file" name="" size="30"> </div> </td> </tr> <tr> <td><input type="submit" name="" value="提交" onclick="comm()"/></td> </tr> </table> </form> </body> </html>
<%@ page language="java" pageEncoding="UTF-8"%> <%@page import="com.jspsmart.upload.SmartUpload"%> <%@page import="com.jspsmart.upload.File"%> <%@page import="com.jspsmart.upload.Files;"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>文件处理页面</title> <script type="text/javascript" src="scripts/jquery.js"></script> <script type="text/javascript" src="scripts/validator.js"></script> <link href="styles/default.css" rel="stylesheet" type="text/css" /> </head> <body> <% String spell = (String)request.getParameter("spell"); SmartUpload su = new SmartUpload();//新建对象 su.initialize(pageContext);//初始化 //设置上传限制 su.setMaxFileSize(10000);//限制每个上传的最大长度 su.setTotalMaxFileSize(20000);//限制总上传数据长度 su.setAllowedFilesList("jpg,JPG,JPEG,png");//限制上传的类型 su.setDeniedFilesList("exe,bat,jsp,html,htm,,");//禁止上传的有拓展名,和没有拓展名的文件 su.upload(); int count = su.save("/flowimages");//保存到指定路径 out.print(count+"个图片上传成功"); Files files = su.getFiles(); File file= files.getFile(0); //将文件另存为 file.saveAs("/flowimages"+spell,su.SAVE_VIRTUAL); %> </body> </html>