阿郎的技术搏客

成长轨迹

简单的上传例子

<html>

<head>

<title>ÎļþÉÏÔØ</title>

</head>

<body>

<form action="upjsp.jsp" enctype="MULTIPART/FORM-DATA" method=post>

<br />

¹«Ë¾: <input type="text" name="company" />

<br />

Ñ¡ÔñÒªÉÏÔصÄÎļþ <input type="file" name="filename" />

<br />

<input type="submit" value="ÉÏÔØ" />

</form>

</body>

</html>
================================END=======================================
<jsp:useBean id="TheBean" scope="page" class="UpBean " />

<%

TheBean.doUpload(request);

%>

================================END=======================================
import java.io.*;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.ServletInputStream;

 

public class UpBean {

 

public void doUpload(HttpServletRequest request) throws

IOException {

PrintWriter pw = new PrintWriter(

new BufferedWriter(new FileWriter("test.txt")));

ServletInputStream in = request.getInputStream();

 

int i = in.read();

while (i != -1) {

pw.print((char) i);

i = in.read();

}

pw.close();

}
}
================================END=======================================

posted on 2007-05-11 18:12 alone 阅读(299) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: