使用 JSP/ Servlet上載文件正成為一項常用的任務
<html>
<body>
<script LANGUAGE="javascript" SRC="JSFunction
</script>
<script language="JavaScript">
<!
function checkForm(){
if (document
alert("You must choose what image file to upload!");
return false;
}
document
}
function cancelUpload(){
window
window
}
//
</script>
<form name="uploadform" method="post"
action="uploadImage
target=_self>
<center>
<table border="
<tr>
<td colspan=
</tr>
<tr>
<td width="
<td width="
name="adsImage" size="
</tr>
<tr>
<td align="center" colspan=
<input type="button" value="upload" onclick="return
checkForm();" >
<input type="button" value="Cancel" onclick="return
cancelUpload();">
</td>
</tr>
</form>
</table>
<!
<a href="Javascript:window
<script language="JavaScript">
<!
this
//
</script>
</body>
<%@ page language="java" import="com
java
<%
<jsp:useBean id="mySmartUpload" scope="page"
class="com
<%
//Initialization
mySmartUpload
mySmartUpload
//Set Restriction
mySmartUpload
mySmartUpload
// Upload
try{
mySmartUpload
}
catch(Exception e){
out
<a href=
"JavaScript:window
out
out
Name
out
out
return;
}
//save file to disk
mySmartUpload
"FileName");
%>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20172.html