⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manual_simple.html

📁 aspupload
💻 HTML
📖 第 1 页 / 共 2 页
字号:
	Other items:<BR>
	DESCR1=bla bla<BR>
	DESCR2=test test<BR>
	</FONT>
	<P>
	<B>IMPORTANT:</B> The Upload.Files and Upload.Form
	collections are populated by the Upload.Save method. Therefore,
	it is incorrect to reference either collection before the Save method
	is called:
	<P>
	<FONT FACE="Courier New" SIZE="2" COLOR="#FF0000">
	<B>
	' Incorrect!<BR>
	Upload.Save( Upload.Form("Path") )
	</B>
	</FONT>

	</BLOCKQUOTE>
	
	<B><FONT COLOR="#0000A0">Referencing Individual File and Form Items</FONT></B>
	<BLOCKQUOTE>

	The previous code sample uses the <B>For-Each</B> loop
	to iterate through the Files and Form collection.
	It is also possible to reference individual file and form items
	via integer or string indices, for example:
	<P>
	<FONT FACE="Courier New" SIZE="2" COLOR="#000000">
	<B>
	Descr1 = Upload.Form("DESCR1")
	<P>
	<I>or</i><P>
	Descr1 = Upload.Form(1)
	</B>
	</FONT>
	<P>
	When referencing an individual item from the Files collection,
	it is a good idea to check whether a file was actually selected
	via the referenced input type=file box, as follows:
	<P>
	<FONT FACE="Courier New" SIZE="2" COLOR="#000000">
	<B>
	Set File = Upload.Files("FILE1")<BR>
	If Not File Is Nothing Then<BR>
	&nbsp;&nbsp;&nbsp;Response.Write File.Path<BR>
	End If	
	</B>
	</FONT>
	<P>
	The Upload.Form collection is not entirely identical to Request.Form as it handles 
	multi-select form items such as &lt;SELECT MULTIPLE> differently.
	<P>
	The sample files <B>Form3.asp</B> and <B>UploadScript3.asp</B> (not shown here) demonstrate
	how to handle all basic input form items with the Upload.Form collection.
	Click the link below to run this code sample:
	<P>
	<B><A TARGET="_new" HREF="http://localhost/aspupload/02_simple/Form3.asp">http://localhost/aspupload/02_simple/Form3.asp</A></B>
	&nbsp;<A HREF="javascript:;" OnClick="open('helppopup.html','','width=400,height=400');"><IMG SRC="help.gif" BORDER="0" ALT="Why is this link not working?"></A>
	<P>
	</BLOCKQUOTE>
	
	<B><FONT COLOR="#0000A0">Unique File Name Generation</FONT></B>
	<BLOCKQUOTE>
	By default, AspUpload overwrites existing files in the upload directory. 
	In a multi-user environment, this is undesirable, as multiple
	users may upload files with the same name.
	<P>
	AspUpload can be configured to generate unique names for the 
	files being uploaded to prevent overwriting existing files in the 
	upload directory. This is done by setting UploadManager's <B>OverwriteFiles</B>
	property to False before calling <B>Upload.Save</B>, as follows:
	<P>
	<FONT FACE="Courier New" SIZE="2" COLOR="#000000">
	<B>Upload.OverwriteFiles = False</B>
	</FONT>
	<P>
	To prevent name collisions, AspUpload appends 
	the original file name with an integer number in parentheses. 
	For example, if the file <B>MyFile.txt</B> already exists in the 
	upload directory, and another file with the same name is being uploaded, 
	AspUpload will save the new file under the name <B>MyFile(1).txt</B>. 
	If more copies of MyFile.txt are uploaded, they will be saved under 
	the names <B>MyFile(2).txt</B>, <B>MyFile(3).txt</B>, etc.
	</BLOCKQUOTE>
	
	<B><FONT COLOR="#0000A0">Setting File Size Limits</FONT></B>
	<BLOCKQUOTE>
	AspUpload is capable of enforcing file size limits by rejecting or 
	truncating uploaded files as specified by the <B>SetMaxSize</B> method. By default, any size files
	are accepted (as long as the total upload does not exceed 2 GB).
	<P>
	The SetMaxSize method expects two arguments: the maximum file size (in bytes)
	and a flag indicating whether a file exceeding the limit should
	be rejected with an error exception thrown (if set to True) or
	truncated (if set to False).
	<P>
	A value set by SetMaxSize is applied to each uploaded file individually rather
	than an entire upload. Since AspUpload has no way of knowing in advance 
	how many files there are in a POST and how large they are, it will always
	allow the upload process to go through, even if the very first file exceeds the 
	specified limit.	
	<P>
	The sample files <B>Form4.asp</B> and <B>UploadScript4.asp</B>
	demonstrate a file upload system with file size limit enforced.
	Here is what the upload script looks like:
	<P>
	<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=3>
	<TR><TD BGCOLOR="#FFFF00">
	<FONT SIZE="1" FACE="Courier New">
	&lt;HTML><BR>
	&lt;BODY><BR>

	&lt;%<BR>
	Set Upload = Server.CreateObject("Persits.Upload")<P>

	' Limit file size to 50000 bytes, throw an exception if file is larger<BR>
	Upload.SetMaxSize 50000, True<P>


	' Intercept all exceptions to display user-friendly error<BR>
	On Error Resume Next<P>

	' Perform upload<BR>
	Upload.Save "c:\upload"<P>

	' 8 is the number of "File too large" exception<BR>
	If Err.Number = 8 Then<BR>
	&nbsp;&nbsp;&nbsp;Response.Write "Your file is too large. Please try again."<BR>
	Else<BR>
	&nbsp;&nbsp;&nbsp;If Err <> 0 Then<BR>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write "An error occurred: " & Err.Description<BR>
	&nbsp;&nbsp;&nbsp;Else<BR>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write "Success!"<BR>
	&nbsp;&nbsp;&nbsp;End If<BR>
	End If<BR>
	%><P>
  

	&lt;/BODY><BR>
	&lt;/HTML>
	</FONT></TD></TR>
	</TABLE>

	<P>

	Click the link below to run this code sample:
	<P>
	<B><A TARGET="_new" HREF="http://localhost/aspupload/02_simple/Form4.asp">http://localhost/aspupload/02_simple/Form4.asp</A></B>
	&nbsp;<A HREF="javascript:;" OnClick="open('helppopup.html','','width=400,height=400');"><IMG SRC="help.gif" BORDER="0" ALT="Why is this link not working?"></A>
	<P>

	</BLOCKQUOTE>	
	<B><FONT COLOR="#0000A0">Placing a Form and Script in the Same File</FONT></B>
	<BLOCKQUOTE>
	If the Upload.Save method is called in a script
	invoked directly rather than via a multipart/form-data form, 
	the following error will occur:
	<P>
	<B>
	<FONT COLOR="red">Persits.Upload.1 (0x800A003D)<BR>
	Wrong Content-Type. Make sure you have included the attribute ENCTYPE="multipart/form-data" in your form.
	</FONT></B>
	<P>
	This creates a problem if you want to place both your form and the corresponding upload script 
	in the same file. To avoid this error, set the property <B>Upload.IgnoreNoPost</B>
	to True.
	<P>
	The code sample <B>BothFormAndScript.asp</B> demonstrates the usage of this
	property.
	<P>
	<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=3>
	<TR><TD BGCOLOR="#FFFF00">
	<FONT SIZE="1" FACE="Courier New">
	&lt;%<BR>
	Set Upload = Server.CreateObject("Persits.Upload")<BR>

	' Do not throw the "Wrong ContentType error first time out<BR>
	Upload.IgnoreNoPost = True<BR>

	Count = Upload.Save("c:\upload")<p>

	If Count > 0 Then<BR>
		Response.Write Count & " file(s) uploaded."<BR>
	End If<BR>
	%><P>

	&lt;HTML><BR>
	&lt;BODY BGCOLOR="#FFFFFF"><BR>

	&lt;h3>Simple Upload&lt;/h3><BR>

		&lt;FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="BothFormAndScript.asp"><BR>
			&lt;INPUT TYPE="FILE" SIZE="40" NAME="FILE1">&lt;BR><BR>
			&lt;INPUT TYPE="FILE" SIZE="40" NAME="FILE2">&lt;BR><BR>
			&lt;INPUT TYPE="FILE" SIZE="40" NAME="FILE3">&lt;BR><BR>
		&lt;INPUT TYPE=SUBMIT VALUE="Upload!"><BR>
		&lt;/FORM><BR>
	&lt;/BODY><BR>
	&lt;/HTML><BR>
	</FONT></TD></TR>
	</TABLE>
	<P>
	Click the link below to run this code sample:
	<P>
	<B><A TARGET="_new" HREF="http://localhost/aspupload/02_simple/BothFormAndScript.asp">http://localhost/aspupload/02_simple/BothFormAndScript.asp</A></B>
	&nbsp;<A HREF="javascript:;" OnClick="open('helppopup.html','','width=400,height=400');"><IMG SRC="help.gif" BORDER="0" ALT="Why is this link not working?"></A>
	<P>

	<A HREF="manual_memory.html"><IMG BORDER="0" SRC="next.gif" ALIGN="RIGHT" ALT="Chapter 3: Uploading to Memory"></A>
	<A HREF="manual_intro.html"><IMG BORDER="0" SRC="previous.gif" ALIGN="RIGHT" ALT="Chapter 1: Introduction"></A>
	<P>&nbsp;
	</BLOCKQUOTE>
	
	


	</FONT>
	<P>
	<TABLE WIDTH=540 HEIGHT=2 CELLSPACING=0 CELLPADDING=0 BORDER=0>
	<TD BGcolor="#FFCE00"><spacer type=block width=540 height=2></TD>
	</TABLE>
	<P>
	<CENTER>
	<A HREF="index.html"><IMG SRC="logo_small.gif" BORDER=0></A>
	<BR>
	<FONT Face=arial size=1>
	Copyright &copy; 1998 - 2001 <A HREF="http://www.persits.com">Persits Software, Inc.</A><BR>
	All Rights Reserved<BR>
	AspUpload&reg; is a registered trademark of Persits Software, Inc.<BR>
	Questions? Comments? <A HREF="MAILTO:info@aspupload.com">Write us!</A>
	</CENTER>

</TD>
</TABLE>

</BASEFONT>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -