`
guoxinzz
  • 浏览: 431664 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

WAP上传图片代码

 
阅读更多

<?xml version= "1.0 " encoding= 'utf-8 '?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN "
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " xml:lang= "en " lang= "en ">
<head>
<meta http-equiv= "content-type " content= "application/vnd.wap.xhtml+xml;charset=UTF-8 "/>
<title> 文件上传 </title>
</head>
<body>
<form name= "form1 " method= "post " action= "up.jsp " enctype= "multipart/form-data ">
密码: <input type= "text " name= "pass "/> <br/>
<input type= "file " name= "file1 "/>
<input type= "submit " name= "submit " value= "· 提交 · "/>
</form>
</body>
</html>
---------------------------------------------
<%@ page import= "org.apache.commons.fileupload.FileItem " %>
<%@ page import= "org.apache.commons.fileupload.servlet.ServletRequestContext " %>
<%@ page import= "java.io.File " %>
<%@ page contentType= "text/vnd.wap.wml;charset=UTF-8 " language= "java " %>
<jsp:useBean id= "fUpload " scope= "page " class= "org.apache.commons.fileupload.FileUpload "/>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN " "http://www.wapforum.org/DTD/wml_1.1.xml ">
<wml>
<card>
<p>
<%
try {
String path = request.getSession().getServletContext().getRealPath( "/ ");
out.println(path);
out.println(request.getParameterMap());
fUpload.setSizeMax(1000000);
out.println( "hi.nihao1 ");
fUpload.setFileItemFactory(new org.apache.commons.fileupload.disk.DiskFileItemFactory());
out.println( "hi.nihao2 ");
java.util.List items = fUpload.parseRequest(new ServletRequestContext(request));
out.println( "hi.nihao3 ");
FileItem fi = (FileItem) items.get(1);
out.println( "hi.nihao4 ");
File uploadFile = new File(path+ "/ "+fi.getName());
out.println( "hi.nihao5 ");
fi.write(uploadFile);
out.println( "hi.nihao6 ");
out.println(request.getSession().getServletContext().getRealPath( "/ "));
} catch (Exception ex) {
ex.printStackTrace(System.out);
out.println( "ERROR~! "+ex);
}
%>
</p>
</card>
</wml>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics