📄 xmanual.htm
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.73 [en] (Windows NT 5.0; U) [Netscape]">
<meta name="Author" content="Persits Software, Inc.">
<title>XUpload Control Manual</title>
</head>
<body BACKGROUND="bk.gif">
<BASEFONT FACE="Arial">
<TABLE WIDTH="750">
<TR>
<TD VALIGN="TOP" WIDTH="80"> </TD>
<TD VALIGN="TOP" WIDTH="670">
<h3><font color="#261257">XUpload 2.1 Programmer's Manual</font></h3>
<blockquote>
<a href="http://www.aspupload.com/xupload.html">http://www.aspupload.com/xupload.html</a>
<p>Copyright (c) 1999 - 2001 <a href="http://www.persits.com">Persits Software,
Inc.</a>
<br>All Rights Reserved.
</blockquote>
<FONT SIZE="2">
<font color="#000099"><B>What is XUpload?</B></font>
<blockquote>XUpload 2.1 is a client-side ActiveX control for uploading
files from a user's machine to the Web server using the RFC1867 standard.
The purpose of XUpload is to overcome numerous limitations of purely browser-based
upload solutions. With XUpload, users can upload files to the server from
a web page viewed by Microsoft Internet Explorer, from a custom application
built with Visual Basic, Visual C++ or any other platform supporting ActiveX,
or directly from File Explorer (see section <i>Using XUpload as a Shell
Extension</i>.)
<p>To upload files to the server, XUpload invokes a server-side upload
component such as <b>AspUpload</b> from Persits Software, Inc. All the
samples in this manual assume that your web server has this component installed.
A free trial copy of the AspUpload component can be downloaded from <a href="http://www.aspupload.com">http://www.aspupload.com</a>.
<p><font color="#000000">Being an ActiveX control, XUpload can only be
used with containers supporting ActiveX. <b>XUpload will not work under
Netscape</b> browsers as they currently do not support ActiveX. XUpload
<b>can
only be used on Win32 platforms</b> such as Windows 95/98/NT/2000.<b> It
will not work on Macintosh or Linux machines.</b></font>
<p><font color="#000000">The XUpload 2.1 control used the Microsoft Internet
Explorer 4.0 WinInet API. Therefore, <b>XUpload requires that Microsoft
Internet Explorer 4.0+ be installed</b>, even if the control is used in
containers other than IE.</font></blockquote>
<font color="#000099"><B>What's New in XUpload 2.1</B></font>
<blockquote><font color="#000000">The following new features have beed
added to XUpload 2.1:</font>
<ul>
<li>
<font color="#000000"><b>IncludeDateInfo</b> property added. Date preservation
can be switched off by setting this property to False. This is useful when
XUpload is used with a server component other than AspUpload.</font></li>
<li>
<font color="#000000"><b>Stop</b> method added. Uploading can now be aborted
programmatically.</font></li>
<li>
<font color="#000000"><b>NTLM (Challenge/Response) Authentication support</b>.
Previous versions of XUpload had problems accessing upload scripts protected
by NTLM. XUpload 2.1 is free of this limitation.</font></li>
<li>
<font color="#000000"><b>Improved Basic Authentication support</b>. XUpload
2.1 displays the standard IE login dialog instead of a custom one.</font></li>
<li>
<font color="#000000"><b>Improved RFC-1867 compliance.</B> Content-Type and
Content-Length headers are explicilty set.</font></li>
<li>
<font color="#000000"><b>Version</B> property added
which enables programmatic access to current version information.</font></li>
<li>
<font color="#000000"><b>Several minor bugs fixed</b>.</font></li>
</ul>
</blockquote>
<font color="#000099"><B>Limitations of Form-based Uploading</B></font>
<blockquote>RFC1867-compliant browsers such as IE 4.0+ or Netscape 3.0+
perform file uploads using an HTML form with the attributes <FORM METHOD="POST"
ENCTYPE="multipart/form-data">. This form must contain one or more items
of the type <INPUT TYPE=FILE>. The browsers display such items as regular
text boxes with the button "Browse..." next to them. Clicking the Browse
button invokes the standard Choose File dialog box which allows the user
to select a file for uploading. The limitations of form-based uploading
are:
<ul>
<li>
The "Choose File" dialog shown by a browser does not allow multiple selections;</li>
<li>
To upload multiple files at once, the HTML form must contain multiple <INPUT
TYPE=FILE> boxes, each file must be selected individually;</li>
<li>
A folder cannot be selected for uploading.</li>
<li>
Default values for the file names cannot be pre-set (the VALUE attribute
is ignored for <INPUT TYPE=FILE> tags);</li>
<li>
There is no progress bar;</li>
<li>
There is no way to set a default directory to select the files from;</li>
<li>
There is no way to specify file filters to be displayed in the <b>Files
of type</b> box of a "Choose File" dialog;</li>
<li>
There is no way to put a limit on the size and number of files being uploaded
before uploading begins;</li>
<li>
There is no way to force users to select files with certain extensions
only;</li>
<li>
Aside from the file path, browsers do not send any information about the
files being uploaded, so the file dates cannot be preserved.</li>
<li>
Uploading cannot be performed in a batch-like process.</li>
</ul>
<font color="#000000">All these limitations can be overcome with the help
of the Persits Software, Inc. <b>XUpload</b> control.</font></blockquote>
<font color="#000099"><B>Getting Ready</B></font>
<blockquote>The XUpload setup program attempts to create the <b>/XUpload</b>
virtusl directory on top of the<b> ...\XUpload\Samples</b> folder of the
installation. Make sure the virtual directory has been successfully created.
If necessary, re-create it. You must also have the AspUpload component
installed and registered on your machine. This upload component can be
downloaded from <a href="http://www.aspupload.com">www.aspupload.com</a>.</blockquote>
<font color="#000099"><B>Using XUpload with Internet Explorer</B></font>
<blockquote>When used with IE, the XUpload control runs inside an HTML
page on a client machine. The HTML page must reference the control using
the <OBJECT> tag, as follows:
<p><b><font face="Courier New,Courier"><font color="#663366"><font size=-1><OBJECT
WIDTH=500 HEIGHT=200</font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#663366"><font size=-1>ID="UploadCtl"</font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#663366"><font size=-1>CLASSID="CLSID:E87F6C8E-16C0-11D3-BEF7-009027438003"</font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#663366"><font size=-1>CODEBASE="XUpload.ocx"></font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#663366"><font size=-1>...</font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#663366"><font size=-1></OBJECT></font></font></font></b>
<p>Generally, XUpload does not need to be registered on the Web server
(because it runs on client machines) but it does need to be placed in a
virtual directory together with HTML pages it is referenced by so that
the browser, after coming across the <OBJECT> tag, can download the
<b>XUpload.ocx</b>
file to the client machine and register it there.
<p>The <b>WIDTH</b> and <b>HEIGHT</b> attributes of the <OBJECT> tag
define the size of the control inside the page. The <b>ID</b> attribute
identifies the XUpload object so that it can be used by client-side VB
Script. The <b>CLASSID</b> attribute specifies the XUpload control's globally
unique identifier (GUID) which the browser uses to create an instance of
the control. The <b>CODEBASE</b> attribute specifies where the file
XUpload.ocx resides relative to the current HTML page.
<p>Fire up your browser and open the URL <b><a href="http://localhost/xupload/simple.htm">http://localhost/xupload/simple.htm</a></b>.
Unless XUpload.ocx was previously registered on your machine, you should
see a dialog box similar to this one:
<p><img SRC="image202.JPG" height=322 width=441>
<br>
<p>The file XUpload.ocx was digitally signed to provide proof to the user
that the control he is about to install on his machine really came from
Persits Software, Inc., and that it was not tempered with during transmission.
Click "Yes" to have the browser install the control on your computer.
<p>You should now be able to see the control inside your browser. It looks
like a regular Win32 list control with two columns, Files and Size. Right-click
anywhere inside the control. A pop-up menu appears with four menu items,
"Select Files", "Select Folder", "Remove All" and "Upload".
<p>The <i>Remove All</i> and <i>Upload</i> items are grayed out as there
is no files selected. Choose <i>Select Files</i> to invoke the standard
"Select Files" dialog box. Choose a few files and click Ok. The selected
files appear in XUpload's list control with their respective icons and
size information. We can now remove any or all files from the list by highlighting
the appropriate items, right-clicking inside the control and choosing <i>Remove</i>
or
<i>Remove</i><b> </b><i>All</i>. We can also sort the items alphabetically
or by size by clicking on the Files or Size headers, respectively.
<p><img SRC="shot1.gif" height=398 width=547>
<p>At the very minimum, you must supply values for two XUpload properties:
<b>Server</b>
and <b>Script</b>. The <b>Server</b> property specifies the address of
a destination web server, such as "www.persits.com" or "192.168.112.221".
The <b>Script</b> property is the path to an upload script on that server,
such as "/upload/myuploadscript.asp". These two properties together serve
the same purpose as the ACTION attribute of an HTML POST form.
<p><font color="#CC0000"><b>NOTE:</b> </font>All the XUpload samples use
the value "localhost" for the <b>Server</b> property and "/xupload/<script
name>.asp" for the <b>Script</b> property. Change these values as necessary.
<p>The properties of an ActiveX control can be specified using <PARAM>
tags placed between the <OBJECT ...> and </OBJECT> tags, for example:
<p><font face="Courier New,Courier"><font color="#663366"><font size=-1><OBJECT
WIDTH=500 HEIGHT=200</font></font></font>
<br><font face="Courier New,Courier"><font color="#663366"><font size=-1> ID="UploadCtl"
CLASSID="CLSID:E87F6C8E-16C0-11D3-BEF7-009027438003" CODEBASE="XUpload.ocx"></font></font></font>
<br><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="Server" VALUE="localhost"></font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="Script" VALUE="/xupload/simple.asp"></font></font></font></b>
<br><font face="Courier New,Courier"><font color="#663366"><font size=-1></OBJECT></font></font></font>
<p>This sample uses the upload script <b>Simple.asp</b> included with the
XUpload control. This script saves uploaded files in the "c:\Upload" directory,
so you should make sure this directory exists or edit the script to specify
a different directory.
<p>Select a few files again and choose "Upload". A dialog box with two
progress bars appears. Once the upload is complete, a message box titled
"Reply from Server" pops up:
<p><img SRC="imageKVQ.JPG" height=119 width=206>
<p>The text inside the message box came directly from the server and was
generated by our upload script. We will see shortly how to make XUpload
redirect the browser to another page upon the completion of an upload.
<p>XUpload can be configured not to display the Reply from Server message
box by setting the <b>ViewServerReply</b> property to False as follows:
<p><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="ViewServerReply" VALUE="False"></font></font></font></b>
<p>If you choose to do so your application may need to provide some other
means to report server replies to the user, such as handling the <b>ServerReply</b>
event (see section <i>Handling Events</i>.)</blockquote>
<b><font color="#000099">Browser Redirection</font></b></h3>
<blockquote>It would be much more intuitive
for the user to have the browser open a different web page upon the completion
of an upload that would display the upload results. XUpload 2.0+ is capable
of doing that. To achive that effect, two ASP scripts are necessary: the
first one works as a regular upload script, and the second does nothing
but display the HTML output generated by the first script. The following
additional parameters (besides the required Server and Script) configure
XUpload to perform the redirection:
<p><b><font face="Courier New,Courier" color="#006600" SIZE="2"><PARAM
NAME="Redirect" VALUE="True">
<br><PARAM NAME="RedirectURL" VALUE="http://localhost/xupload/showreply.asp"></font></b>
<p>The <b>Redirect</b> propery, if set to True, instructs
XUpload not to display the HTML stream received from the upload script.
Instead, XUpload POSTs the upload results to the URL specifed by the RedirectURL
parameter, in the following format:
<p><b><tt><font color="#000000">XUPLOADREPLY=<<i>URL-encoded results</i>></font></tt></b>
<p>Therefore, the script <b>showreply.asp</b> can
be as simple as this single line of ASP code:
<br>
<table BORDER CELLSPACING=0 CELLPADDING=0 COLS=1 WIDTH="55%" BGCOLOR="#FFFFCC">
<tr>
<td NOWRAP><b><font face="Courier New,Courier"><font size=-1><% Response.Write
Request.Form("XUPLOADREPLY") %></font></font></b></td>
</tr>
</table>
</blockquote>
<blockquote><font color="#000000">The redirection technique
is demonstrated by the sample files <b>Redirect.htm</b>, <b>Draddrop.htm</b>,
<b>Directories.htm</b>,
<b>FormItems.htm</b>
and <b>Buttons.htm</b>. It is also demonstrated by the XUpload live demo
at <b><a href="http://aspupload.com/xupload/livedemo.html">http://www.aspupload.com/xupload/livedemo.html</a></b>.</font>
<p><font color="#000000">Note: if the <b>Redirect</b> property
is set to True, the <b>ViewServerReply</b> property will be ignored and
assumed False.</font></blockquote>
<b><font color="#000099">Configuring <i>Select Files for Uploading</i>
Dialog</font></b>
<blockquote><font color="#000000">An important advantage of XUpload over
a purely browser-based solution is being able to specify the "Select Files"
dialog's default directory and file filters. The corresponding properties
are <b>Directory</b> and <b>Filter</b>. The usage of the <b>Directory</b>
property is straightforward:</font>
<p><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="Directory" VALUE="c:\My Documents\Spreadsheets"></font></font></font></b>
<p><font color="#000000">The <b>Filter</b> property accepts a list of pairs
separated by the pipe character ( | ). Each pair defines a verbal description
for a filter and the filter itself which may contain one or more wildcards
separated by a semicolon (;). The two values in the pair are also separated
by the pipe character. For example,</font>
<p><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="Filter" VALUE="Images (.gif;.jpg)|*.gif;*.jpg|Documents (.doc)|*.doc|All
Files|*.*"></font></font></font></b>
<p><font color="#000000">Here we specify three filters. The first filter
has the verbal description "Images (.gif;.jpg)" and consists of two wildcards,
*.gif and *.jpg. The second filter has the description "Documents (.doc)"
and is defined by the wildcard *.doc. The third filter is "All Files" with
the wildcard *.*.</font></blockquote>
<font color="#000099"><B>Setting Limits on Files Being Uploaded</B></font>
<blockquote>XUpload enables you to impose certain restrictions on the files
being uploaded, so that the files not meeting the restrictions are rejected
<u>before</u>
an upload begins. The restrictions are set via the propteries MaxFileCount,
MaxFileSize, MaxTotalSize and Extensions. The <b>MaxFileCount</b> property,
if set to a non-zero value, limits the total number of files selected for
uploading. The <b>MaxFileSize</b> property, if set to a non-zero value,
places a limit on the size of individual files (in bytes). The <b>MaxTotalSize</b>
property, if set to a non-zero value, sets a limit on the total size of
files selected for uploading (in bytes). These three properties are 0 by
default. The <b>Extensions</b> property can be used to specify a list of
acceptable file extensions. For example,
<p><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="MaxFileSize" VALUE="50000"></font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="MaxTotalSize" VALUE="200000"></font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="MaxFileCount" VALUE="10"></font></font></font></b>
<br><b><font face="Courier New,Courier"><font color="#006600"><font size=-1><PARAM
NAME="Extensions" VALUE="gif,doc,jpg"></font></font></font></b>
<p>The <b>Extensions</b> restriction is enforced at the time of adding
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -