Directory Upload: Using XFile
FileUpcan process an upload of a full directory and its subdirectories. This can be done
using
FileUpin combination with
SoftArtisans XFile.
Scripting a Recursive Upload with SoftArtisans XFile
The Server-Side Script
Scripting a Recursive Upload with SoftArtisans XFile
Use the XFRequest object's method,AddDirectoryRecursive
to upload a
directory. For example:
The Client Code |
<script language="vbscript">
Sub UploadButton_OnClick()
'-- Set the URL where we want to send the data by '-- using the CurrentURL property XFRequest.CurrentURL =
"http://localhost/SAFileUpSamples/Recursive/Xfile/"
& _ "ResurXfileResp.asp"
'--- Add Directory and subdirectory with all files XFRequest.AddDirectoryRecursive("C:\temp\download")
' -- Start the transfer XFRequest.Start End Sub
</script>
|
Top
The Server-Side Script
In the upload processing script on the server, use FileUp's SaveRecursive()
method instead of Save
or SaveAs
.
The following code shows what your response page looks like:
<% '--- Create an instance of FileUp Set fileUpload = Server.CreateObject("SoftArtisans.FileUp")
fileUpload.Path = "D:\Uploads"
'--- Save full directory of files fileUpload.SaveRecursive()
%>
|
If you plan to display the properties of the uploaded file when the transfer is
complete, code your page as if you were uploading multiple files. For example:
<table width="95%" border="1" cellspacing="2"
cellpadding="0" height="206"> <tr> <th colspan="2"><p align="center">Contents
of The Form</p></th> </tr> <tr> <th width="20%"><p align="center"><center>Tag
Name</p></th> <th width="80%"><p align="center"><center>Value</p></th> </tr> <% For Each item In fileUpload.Form Response.Write("<tr><td align=""right"">"
& _ item & "</td>") If Not IsObject(fileUpload.Form(item)) Then '--- This is a regular (non-file) form element.
Show its value Response.write("<td>" &
fileUpload.Form(item) & "</td></tr>") Else '--- This is a form element. Show all the details %> <td> <table width="100%" border="1"
cellspacing="2"
cellpadding="0"
height="206"> <tr> <th colspan="2"><p
align="center">File Details</p></th> </tr> <tr> <th width="35%"><p
align="center"><center>Item</p></th> <th width="65%"><p
align="center"><center>Value</p></th> </tr> <tr> <td width="35%"
align="right" valign="top"> Server filename</td> <td width="65%"><%=fileUpload.Form(item).ServerName%> </td> </tr> <tr> <td width="35%"
align="right" valign="top"> User's filename</td> <td width="65%"><%=fileUpload.Form(item).UserFilename%> </td> </tr> </table></td> </tr> <%
End If Next %>
|
For more examples, check out the samples provided as part of the
FileUpdistribution. See Programmer's Samples for a list of the contents of the Samples
directory.
Top
Copyright © 2010 SoftArtisans, Inc. All rights reserved.