哪位大哥帮我下,我用jspsmartupload上传图片,好像已经上传,但文件夹里找不到
html页面部分代码:<formaction="smartupload04.jsp"method="post"enctype="multipart/form-data">...
html页面部分代码:
<form action="smartupload04.jsp" method="post" enctype="multipart/form-data">
文件名称:<input type="text" name="uname"><br>
上传的图片:<input type="file" name="pic"><br>
<input type="submit" value="上传">
</form>
================smartupload04.jsp代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<jsp:useBean id="smartupload" class="com.jspsmart.upload.SmartUpload"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'smartupload04.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
request.setCharacterEncoding("GBK") ;
smartupload.initialize(pageContext) ; // 初始化上传
smartupload.upload() ; // 准备上传
String name = smartupload.getRequest().getParameter("uname") ;
name = name + "." + smartupload.getFiles().getFile(0).getFileExt() ;
String fileName = this.getServletContext().getRealPath("/") + "upload/" + name ;
smartupload.getFiles().getFile(0).saveAs(fileName) ;
%>
<img src="upload/<%=name%>" width="300" height="200"><%=name %>
</body>
</html>
谢谢了,或者那位大吓帮我远程看下也行,Q:四六零九一三八九五 展开
<form action="smartupload04.jsp" method="post" enctype="multipart/form-data">
文件名称:<input type="text" name="uname"><br>
上传的图片:<input type="file" name="pic"><br>
<input type="submit" value="上传">
</form>
================smartupload04.jsp代码:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<jsp:useBean id="smartupload" class="com.jspsmart.upload.SmartUpload"/>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'smartupload04.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
request.setCharacterEncoding("GBK") ;
smartupload.initialize(pageContext) ; // 初始化上传
smartupload.upload() ; // 准备上传
String name = smartupload.getRequest().getParameter("uname") ;
name = name + "." + smartupload.getFiles().getFile(0).getFileExt() ;
String fileName = this.getServletContext().getRealPath("/") + "upload/" + name ;
smartupload.getFiles().getFile(0).saveAs(fileName) ;
%>
<img src="upload/<%=name%>" width="300" height="200"><%=name %>
</body>
</html>
谢谢了,或者那位大吓帮我远程看下也行,Q:四六零九一三八九五 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询