Q1. I want to let my users specify the destination directory to which the files will be uploaded. I included <INPUT TYPE="TEXT" NAME="PATH"> in the form, and my upload script looks like this: <% n = Upload.Save(Upload.Form("Path")) %>. However this does not seem to work.
A. You can not use the Form collection before calling Save because it is not yet populated. The right way to do it is to upload the files to a temporary directory and then copy or move them to the specified destination directory as follows:
<%
n = Upload.Save
"c:\upload"
For Each
File in Upload.Files
File.Copy
Upload.Form("Path") & "\" & File.ExtractFileName
Next
%>
A: No. Early versions of the ASP's Request
object did not provide the BinaryRead
or TotalBytes methods which the
component heavily relies on. The best way to test whether your version
of ASP allows uploading is to execute a simple script like <%
n = Request.TotalBytes %> and see if the method is recognized by
your ASP module.
A: It depends on the type and version of your
web server. If you are using PWS or IIS 3.0 you can download the latest
version of ASP from http://www.microsoft.com/office/intranet/modules/asp411s3.asp.
If you are using IIS 4.0 you may need to install
Option Pack 4 downloadable from http://www.microsoft.com/iis.
A: One possible reason is that your version of ASP is old. See Q2
and Q3. Another possible reason is that you forgot to include the
METHOD=POST
attribute in your form.
A. It most probably means that your version of ASP is old and does not
support the Request.BinaryRead method. See Q2 and Q3.
A: By default, no. You need to install an
IE3 upload add-on available from http://www.microsoft.com/msdownload/iebuild/ie3add_win32/en/ie3add_win32.htm.
A. Set the Session.Timeout property
to some large number such as 200 (in minutes) before calling Upload.Save.
A. Yes. Unlike Request.Form, the Upload.Form collection will store each selected string as an individual item, but under the same name. You can access all selected strings as follows:
<%
For Each
Item in Upload.Form
If Item.Name = "Choice" Then Response.Write Item.Value & "<BR>"
Next
%>