<html>
<%@ page language="java" import="javazoom.upload.*,java.util.*,java.io.*" %>
<%@ page errorPage="ExceptionHandler.jsp" %><% String directory = "D:/Program Files/Tomcat 5.5/webapps/ROOT/rjgc/upload/uploads/"; %>
<% String tmpdirectory = "D:/Program Files/Tomcat 5.5/webapps/ROOT/rjgc/upload/uploads/tmp"; %>
<% boolean createsubfolders = true; %>
<jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
<jsp:setProperty name="upBean" property="folderstore" value="<%= directory %>" />
<jsp:setProperty name="upBean" property="parser" value="<%= MultipartFormDataRequest.CFUPARSER %>"/>
<jsp:setProperty name="upBean" property="parsertmpdir" value="<%= tmpdirectory %>"/>
<jsp:setProperty name="upBean" property="filesizelimit" value="8589934592"/>
</jsp:useBean><head>
<title>Samples : Large Upload</title>
<style TYPE="text/css">
<!--
.style1 {
font-size: 12px;
font-family: Verdana;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<ul class="style1">
<%
if (MultipartFormDataRequest.isMultipartFormData(request))
{
// Uses MultipartFormDataRequest to parse the HTTP request.
MultipartFormDataRequest mrequest = null;
try
{
mrequest = new MultipartFormDataRequest(request,null,-1);
} catch (Exception e)
{
// Cancel current upload (e.g. Stop transfert)
}
String todo = null;
if (mrequest != null) todo = mrequest.getParameter("todo");
if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
{
Hashtable files = mrequest.getFiles();
if ( (files != null) && (!files.isEmpty()) )
{
UploadFile file = (UploadFile) files.get("uploadfile");
if (file != null) out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
// Uses the bean now to store specified by jsp:setProperty at the top.
String relative = mrequest.getParameter("relativefilename");
if ((createsubfolders == true) && (relative != null))
{
int inda=relative.length();
int indb=file.getFileName().length();
if (inda > indb)
{
String subfolder = relative.substring(0,(inda-indb)-1);
subfolder = subfolder.replace('\\','/').replace('/',java.io.File.separatorChar);
upBean.setFolderstore(directory+java.io.File.separator+subfolder);
}
}
upBean.store(mrequest, "uploadfile");
String chunkidStr = mrequest.getParameter("chunkid");
String chunkamountStr = mrequest.getParameter("chunkamount");
String chunkbaseStr = mrequest.getParameter("chunkbase");
if ((chunkidStr != null) && (chunkamountStr != null) && (chunkbaseStr != null))
{
int chunkid = Integer.parseInt(chunkidStr);
int chunkamount = Integer.parseInt(chunkamountStr);
if (chunkid == chunkamount)
{
// recompose file.
String fname = upBean.getFolderstore()+java.io.File.separator+chunkbaseStr;
File fread = new File(fname);
if (fread.canRead()) fname = fname+"."+System.currentTimeMillis();
FileOutputStream fout = new FileOutputStream(fname);
byte[] buffer = new byte[4096];
for (int c=1;c<=chunkamount;c++)
{
File filein = new File(upBean.getFolderstore()+java.io.File.separator+chunkbaseStr+"."+c);
FileInputStream fin = new FileInputStream(filein);
int read = -1;
while ((read = fin.read(buffer)) > 0) fout.write(buffer,0,read);
fin.close();
filein.delete();
}
fout.close();
}
}
upBean.setFolderstore(directory);
}
else
{
out.println("<li>No uploaded files");
}
}
else out.println("<BR> todo="+todo);
}
%>
</ul>
<form method="post" action="LargeUpload.jsp" name="upform" enctype="multipart/form-data">
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
<tr>
<td align="left"><b>Select a file to upload :</b></td>
</tr>
<tr>
<td align="left"><input type="file" name="uploadfile" size="50"></td>
</tr>
<tr>
<td align="left">
<input type="hidden" name="todo" value="upload">
<input type="submit" name="Submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">
</td>
</tr>
</table>
<br>
<br>
<table border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td bgcolor="#666666">
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="center" class="style1">
<tr>
<td bgcolor="#FFFFFF"><b><font color="#0000FF">
HTML tags used in this form : </font></b></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> <<b>form</b>
<b>method</b>="<b><font color="#FF0000">post</font></b>"
<b>action</b>="<b><font color="#FF0000">LargeUpload.jsp</font></b>"
name="upload" <b>enctype</b>="<b><font color="#FF0000">multipart/form-data</font></b>"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> <<b>input</b>
<b>type</b>="<b><font color="#FF0000">file</font></b>"
<b>name</b>="<font color="#FF0000"><b>uploadfile</b></font>"
size="50"></td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</form>
</body>
</html>
<%@ page language="java" import="javazoom.upload.*,java.util.*,java.io.*" %>
<%@ page errorPage="ExceptionHandler.jsp" %><% String directory = "D:/Program Files/Tomcat 5.5/webapps/ROOT/rjgc/upload/uploads/"; %>
<% String tmpdirectory = "D:/Program Files/Tomcat 5.5/webapps/ROOT/rjgc/upload/uploads/tmp"; %>
<% boolean createsubfolders = true; %>
<jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
<jsp:setProperty name="upBean" property="folderstore" value="<%= directory %>" />
<jsp:setProperty name="upBean" property="parser" value="<%= MultipartFormDataRequest.CFUPARSER %>"/>
<jsp:setProperty name="upBean" property="parsertmpdir" value="<%= tmpdirectory %>"/>
<jsp:setProperty name="upBean" property="filesizelimit" value="8589934592"/>
</jsp:useBean><head>
<title>Samples : Large Upload</title>
<style TYPE="text/css">
<!--
.style1 {
font-size: 12px;
font-family: Verdana;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<ul class="style1">
<%
if (MultipartFormDataRequest.isMultipartFormData(request))
{
// Uses MultipartFormDataRequest to parse the HTTP request.
MultipartFormDataRequest mrequest = null;
try
{
mrequest = new MultipartFormDataRequest(request,null,-1);
} catch (Exception e)
{
// Cancel current upload (e.g. Stop transfert)
}
String todo = null;
if (mrequest != null) todo = mrequest.getParameter("todo");
if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
{
Hashtable files = mrequest.getFiles();
if ( (files != null) && (!files.isEmpty()) )
{
UploadFile file = (UploadFile) files.get("uploadfile");
if (file != null) out.println("<li>Form field : uploadfile"+"<BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+"<BR> Content Type : "+file.getContentType());
// Uses the bean now to store specified by jsp:setProperty at the top.
String relative = mrequest.getParameter("relativefilename");
if ((createsubfolders == true) && (relative != null))
{
int inda=relative.length();
int indb=file.getFileName().length();
if (inda > indb)
{
String subfolder = relative.substring(0,(inda-indb)-1);
subfolder = subfolder.replace('\\','/').replace('/',java.io.File.separatorChar);
upBean.setFolderstore(directory+java.io.File.separator+subfolder);
}
}
upBean.store(mrequest, "uploadfile");
String chunkidStr = mrequest.getParameter("chunkid");
String chunkamountStr = mrequest.getParameter("chunkamount");
String chunkbaseStr = mrequest.getParameter("chunkbase");
if ((chunkidStr != null) && (chunkamountStr != null) && (chunkbaseStr != null))
{
int chunkid = Integer.parseInt(chunkidStr);
int chunkamount = Integer.parseInt(chunkamountStr);
if (chunkid == chunkamount)
{
// recompose file.
String fname = upBean.getFolderstore()+java.io.File.separator+chunkbaseStr;
File fread = new File(fname);
if (fread.canRead()) fname = fname+"."+System.currentTimeMillis();
FileOutputStream fout = new FileOutputStream(fname);
byte[] buffer = new byte[4096];
for (int c=1;c<=chunkamount;c++)
{
File filein = new File(upBean.getFolderstore()+java.io.File.separator+chunkbaseStr+"."+c);
FileInputStream fin = new FileInputStream(filein);
int read = -1;
while ((read = fin.read(buffer)) > 0) fout.write(buffer,0,read);
fin.close();
filein.delete();
}
fout.close();
}
}
upBean.setFolderstore(directory);
}
else
{
out.println("<li>No uploaded files");
}
}
else out.println("<BR> todo="+todo);
}
%>
</ul>
<form method="post" action="LargeUpload.jsp" name="upform" enctype="multipart/form-data">
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
<tr>
<td align="left"><b>Select a file to upload :</b></td>
</tr>
<tr>
<td align="left"><input type="file" name="uploadfile" size="50"></td>
</tr>
<tr>
<td align="left">
<input type="hidden" name="todo" value="upload">
<input type="submit" name="Submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">
</td>
</tr>
</table>
<br>
<br>
<table border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td bgcolor="#666666">
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="center" class="style1">
<tr>
<td bgcolor="#FFFFFF"><b><font color="#0000FF">
HTML tags used in this form : </font></b></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> <<b>form</b>
<b>method</b>="<b><font color="#FF0000">post</font></b>"
<b>action</b>="<b><font color="#FF0000">LargeUpload.jsp</font></b>"
name="upload" <b>enctype</b>="<b><font color="#FF0000">multipart/form-data</font></b>"></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> <<b>input</b>
<b>type</b>="<b><font color="#FF0000">file</font></b>"
<b>name</b>="<font color="#FF0000"><b>uploadfile</b></font>"
size="50"></td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</form>
</body>
</html>
<%@ page language="java" import="javazoom.upload.*,java.util.*,java.io.*" %>
<%@ page errorPage="ExceptionHandler.jsp" %>
//脚本中定义几个变量
<% String directory = "D:/Program Files/Tomcat 5.5/webapps/ROOT/rjgc/upload/uploads/"; %>
<% String tmpdirectory = "D:/Program Files/Tomcat 5.5/webapps/ROOT/rjgc/upload/uploads/tmp"; %>
<% boolean createsubfolders = true; %>
//引入 javaBean
<jsp:useBean id="upBean" scope="page" class="javazoom.upload.UploadBean" >
<jsp:setProperty name="upBean" property="folderstore" value=" <%= directory %>" />
<jsp:setProperty name="upBean" property="parser" value=" <%= MultipartFormDataRequest.CFUPARSER %>"/>
<jsp:setProperty name="upBean" property="parsertmpdir" value=" <%= tmpdirectory %>"/>
<jsp:setProperty name="upBean" property="filesizelimit" value="8589934592"/>
</jsp:useBean> <head>
<title>Samples : Large Upload </title>
<style TYPE="text/css">
<!--
.style1 {
font-size: 12px;
font-family: Verdana;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<ul class="style1">
<%
//判断是否为 Multipart类型的表单。即 带有文件上传功能的。 if (MultipartFormDataRequest.isMultipartFormData(request))
{
// Uses MultipartFormDataRequest to parse the HTTP request.
MultipartFormDataRequest mrequest = null;
try
{
mrequest = new MultipartFormDataRequest(request,null,-1);
} catch (Exception e)
{
// Cancel current upload (e.g. Stop transfert)
}
String todo = null;
if (mrequest != null) todo = mrequest.getParameter("todo");
if ( (todo != null) && (todo.equalsIgnoreCase("upload")) )
{
Hashtable files = mrequest.getFiles();
if ( (files != null) && (!files.isEmpty()) )
{ UploadFile file = (UploadFile) files.get("uploadfile");
if (file != null) out.println(" <li>Form field : uploadfile"+" <BR> Uploaded file : "+file.getFileName()+" ("+file.getFileSize()+" bytes)"+" <BR> Content Type : "+file.getContentType());
// Uses the bean now to store specified by jsp:setProperty at the top.
String relative = mrequest.getParameter("relativefilename");
if ((createsubfolders == true) && (relative != null))
{
int inda=relative.length();
int indb=file.getFileName().length();
if (inda > indb)
{
String subfolder = relative.substring(0,(inda-indb)-1);
subfolder = subfolder.replace('\\','/').replace('/',java.io.File.separatorChar);
upBean.setFolderstore(directory+java.io.File.separator+subfolder);
}
}
//获得各个表单控件的值。 upBean.store(mrequest, "uploadfile");
String chunkidStr = mrequest.getParameter("chunkid");
String chunkamountStr = mrequest.getParameter("chunkamount");
String chunkbaseStr = mrequest.getParameter("chunkbase");
if ((chunkidStr != null) && (chunkamountStr != null) && (chunkbaseStr != null))
{
int chunkid = Integer.parseInt(chunkidStr);
int chunkamount = Integer.parseInt(chunkamountStr);
if (chunkid == chunkamount)
{
// recompose file.
String fname = upBean.getFolderstore()+java.io.File.separator+chunkbaseStr;
File fread = new File(fname);
if (fread.canRead()) fname = fname+"."+System.currentTimeMillis();
FileOutputStream fout = new FileOutputStream(fname);
//在服务端生成一个新文件。 byte[] buffer = new byte[4096];
for (int c=1;c <=chunkamount;c++)
{
File filein = new File(upBean.getFolderstore()+java.io.File.separator+chunkbaseStr+"."+c);
FileInputStream fin = new FileInputStream(filein);
int read = -1;
while ((read = fin.read(buffer)) > 0) fout.write(buffer,0,read);
fin.close();
filein.delete();
}
fout.close();
}
}
upBean.setFolderstore(directory);
}
else
{
out.println(" <li>No uploaded files");
}
}
else out.println(" <BR> todo="+todo);
}
%>
</ul>
<form method="post" action="LargeUpload.jsp" name="upform" enctype="multipart/form-data">
<table width="60%" border="0" cellspacing="1" cellpadding="1" align="center" class="style1">
<tr>
<td align="left"> <b>Select a file to upload : </b> </td>
</tr>
<tr>
<td align="left"> <input type="file" name="uploadfile" size="50"> </td>
</tr>
<tr>
<td align="left">
<input type="hidden" name="todo" value="upload">
<input type="submit" name="Submit" value="Upload">
<input type="reset" name="Reset" value="Cancel">
</td>
</tr>
</table>
<br>
<br>
<table border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td bgcolor="#666666">
<table width="100%" border="0" cellspacing="1" cellpadding="0" align="center" class="style1">
<tr>
<td bgcolor="#FFFFFF"> <b> <font color="#0000FF">
HTML tags used in this form : </font> </b> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> < <b>form </b>
<b>method </b>=" <b> <font color="#FF0000">post </font> </b>"
<b>action </b>=" <b> <font color="#FF0000">LargeUpload.jsp </font> </b>"
name="upload" <b>enctype </b>=" <b> <font color="#FF0000">multipart/form-data </font> </b>"> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> < <b>input </b>
<b>type </b>=" <b> <font color="#FF0000">file </font> </b>"
<b>name </b>=" <font color="#FF0000"> <b>uploadfile </b> </font>"
size="50"> </td>
</tr>
</table>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p>
</form>
</body>
</html>