Multiple File Upload in Classic ASP
One dialog, many files, one queue — with the server-side loop that reads all of them.
Getting the browser to offer more than one file
The HTML side is genuinely easy now. A single attribute does it:
<form method="POST" enctype="multipart/form-data">
<input type="file" name="myfiles" multiple />
<input type="submit" value="Upload" />
</form>
With multiple, the file dialog lets the user ctrl-click or shift-click a selection, and
modern browsers also accept files dragged onto the input. No Flash, no Silverlight, no ActiveX —
those workarounds are long dead and any tutorial recommending them is out of date.
You can steer the dialog with accept, e.g.
accept="image/*" or accept=".jpg,.png,.zip". It is a convenience filter
only — the user can still switch the dialog to "All files", so it is not validation.
The server side is where it gets awkward
Now the request body contains several parts, one per file, each with its own boundary and headers:
-----------------------------7d5a2
Content-Disposition: form-data; name="myfiles"; filename="one.jpg"
Content-Type: image/jpeg
<bytes>
-----------------------------7d5a2
Content-Disposition: form-data; name="myfiles"; filename="two.png"
Content-Type: image/png
<bytes>
-----------------------------7d5a2--
A hand-written parser now has to loop boundaries rather than find one, and every byte of every file is in memory at once. Ten 20 MB photos is a 200 MB allocation before you have saved anything. This is the point where do-it-yourself parsing usually stops being worth it.
Multiple file upload with ASP Uploader
One property turns it on, and each file travels as its own background request — so ten files cost the same server memory as one:
<%@ Language="VBScript" %>
<!-- #include file="aspuploader/include_aspuploader.asp" -->
<form id="form1" method="POST">
<%
Dim uploader
Set uploader = new AspUploader
uploader.Name = "myuploader"
uploader.MultipleFilesUpload = true ' <-- the switch
uploader.MaxSizeKB = 10240
uploader.InsertText = "Upload File (Max 10M)"
uploader.AllowedFileExtensions = "*.jpg,*.png,*.gif,*.zip"
%>
<%= uploader.GetString() %>
<input type="submit" value="Submit Form" />
</form>
The rendered control shows a queue: one row per file, each with its own status and its own progress. Users can add more files while the first ones are still transferring, and cancel an individual file without losing the rest.
Reading every uploaded file
On postback, the form field named after the uploader holds a "/"-separated list of GUIDs. Split it and loop:
<%
If Request.Form("myuploader") & "" <> "" Then
Dim list, i, mvcfile
list = Split(Request.Form("myuploader"), "/")
Response.Write "<p>" & (UBound(list) + 1) & " file(s) received</p>"
For i = 0 To UBound(list)
Set mvcfile = uploader.GetUploadedFile(list(i))
Response.Write mvcfile.FileName & " - " & mvcfile.FileSize & " bytes<br/>"
mvcfile.MoveTo Server.MapPath("uploads/" & mvcfile.FileName)
Next
End If
%>
Files you never move are cleaned out of the temp folder automatically, so an abandoned form does not leak disk.
Handling duplicate file names
Ten users uploading scan.pdf will overwrite each other. Give each file a unique
destination and keep the original name as data, not as a path:
<%
Dim ext, newName
For i = 0 To UBound(list)
Set mvcfile = uploader.GetUploadedFile(list(i))
ext = ""
If InStrRev(mvcfile.FileName, ".") > 0 Then
ext = Mid(mvcfile.FileName, InStrRev(mvcfile.FileName, "."))
End If
' list(i) is already a GUID - reuse it as the stored name
newName = list(i) & ext
mvcfile.MoveTo Server.MapPath("uploads/" & newName)
' store newName + mvcfile.FileName (the display name) in your database
Next
%>
Capping how many files can be queued
uploader.MaxFilesLimit = 20
uploader.MaxFilesLimitMsg = "You can upload at most 20 files at a time."
Two patterns worth knowing
Upload immediately vs. upload on submit
By default files start transferring as soon as they are selected, so by the time the user finishes the
rest of the form the upload is already done. If you would rather they queue up and start on a button
click, set ManualStartUpload:
uploader.ManualStartUpload = true
Keeping files across several postbacks
If the form posts back more than once — validation errors, a multi-step wizard — carry the accumulated GUID list in a hidden field so earlier files are not forgotten:
<%
Dim processedlist
processedlist = Request.Form("processedlist") & ""
If Request.Form("myuploader") & "" <> "" Then
If processedlist = "" Then
processedlist = Request.Form("myuploader")
Else
processedlist = processedlist & "/" & Request.Form("myuploader")
End If
End If
%>
<input type="hidden" name="processedlist" value="<%= processedlist %>" />
Now every previously uploaded file is still addressable on the final submit. There is a live demo of this pattern.
Frequently asked questions
How do I upload multiple files at once in Classic ASP?
Add the multiple attribute to the file input and loop the parts server-side, or set
MultipleFilesUpload = true on ASP Uploader and loop the returned GUID list.
Is there a limit on how many files can be uploaded together?
The browser does not impose a practical one. Use MaxFilesLimit to set your own.
Do multiple files upload in parallel or one after another?
ASP Uploader transfers them sequentially by default, which keeps memory flat and gives accurate per-file progress.
Skip the plumbing
ASP Uploader does everything on this page out of the box: multi-file selection, a real progress bar, client and server validation, chunked large-file transfer, and no COM component to register. Drop the folder on your server and add one include line.