Click here to Skip to main content
Click here to Skip to main content

File Upload using a VBScript Class

, 29 May 2002
Rate this:
Please Sign up or sign in to vote.
Using a VBScript class to upload files. Useful when you are not able to deploy a custom COM object.
<!-- Download Links --> <!-- Add the rest of your HTML here -->


There are several components on the market that allow your ASP application to handle file uploads. But when you are in a situation where in you are not allowed to install any components then this vbsUpload will be helpful to you. During my Academic Project I was not allowd to use the components on the server and hence found an alternative to Upload the Files from the client end.

Code Support

This is the file which contains the whole logic of the File Upload. The Request.Binary read method is used to read the raw data sent by the client as part of a POST request. ASP provides a method to apply URL encoding rules, but no publicly exposed way to decode. The URLDecode method does that URLDecoding. Then the raw data is parsed and the File elements and Form Elements are separately kept in two collection objects.

This is a simple asp file used to Upload the multipart/form-data. Once the data is available this file will save the file on the hard disk. The file is as follows:
<%@ Language="VBScript" %>
<!--<span class="code-comment"> #include file="vbsUpload.asp" --></span>
<form method=post
Your File:<BR><input type=file name=YourFile><BR><BR>
<input type=submit name=submit value="Upload">
Dim objUpload, lngLoop

If Request.TotalBytes > 0 Then
	Set objUpload = New vbsUpload

  For lngLoop = 0 to objUpload.Files.Count - 1
    'If accessing this page annonymously,
    'the internet guest account must have
    'write permission to the path below.
    objUpload.Files.Item(lngLoop).Save "c:\Newupload\"

	Response.Write "File Uploaded"

End if
This is another simple file to get multipart/form-data but this will save the data in the Database

This is for using SQLServer to store the files. I have provided the Script to create the Table. So you can create the same table format and use it. Don't forget to fill in the correct Connection String.

This file is used to retreive the binay data from the Database and to display on the Web.
Note: The binary data is written into a file using "Scripting.FileSystemObject" CreateTextFile method. This is not working properly in the case of Excel and other binary files. So limit your usuage only with plain text file. When the file is uploaded to database, the content type is noted and the binary content is saved as Image data type in the SQL Server. Using download.asp the binary data is written back to the client with the proper content type. So there is no problem with the Database File Upload&download. You can upload all the file types (Excel,jpg etc..) using Process_DB.asp.


Now it is easy for me to handle file uploads using ASP and VBScript. I was using this on Windows 2000 Server and Internet Explorer 5. There may be bugs on other versions of the server or client. Please treat this code as a demo version only. It is not meant for production use unless other wise you make it that way.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author


Hong Kong Hong Kong
No Biography provided

Comments and Discussions

GeneralMy vote of 3 PinmemberMember 771757416-Apr-11 6:16 
GeneralRe: My vote of 3 Pinmemberkrupalali26-May-11 23:20 
Me too vote 3 for this article...
GeneralBest Ever ASP Uploader PinmemberAlbee Tang21-Jan-11 22:43 
GeneralMy vote of 5 PinmemberAlbee Tang21-Jan-11 22:41 
GeneralobjUpload.Files.Count is 0 PinmemberMember 194710423-Apr-10 3:57 
GeneralError in using vbsUpload.asp PinmemberMember 12675465-Sep-09 4:17 
Questionhi urgent plz PinmemberMember 426072323-Feb-09 21:24 
GeneralWant to call the webpage inside a vbs and upload a file automaticly...need some help Pinmembernelsonribeiro13-Feb-09 14:01 
QuestionThere appears to be a size limit - is this correct? PinmemberRupert Dick8-Oct-08 7:52 
Questionhow get reports of all files from database PinmemberNageshbijoor22-Aug-08 23:59 
Questionimmediately needed PinmemberLalithaSundaresan2-Apr-08 0:57 
Questionscript to get the name of uploaded Pinmemberleeechoobkeong27-Aug-07 19:16 
AnswerRe: script to get the name of uploaded PinmemberNageshbijoor22-Aug-08 23:54 
Generalthanks Pinmemberlandan21-Aug-07 18:55 
Generalurgent Please PinmemberMErV -The DEV14-Aug-07 2:04 
QuestionHow to upload big File size Pinmemberlong_great22-Jul-07 23:47 
GeneralGetting error PinmemberNikhil_maverick23-Mar-07 11:27 
GeneralRe: Getting error Pinmemberevilmonkey001324-Apr-07 14:46 
GeneralRe: Getting error Pinmemberlong_great22-Jul-07 23:14 
QuestionUploading multiple files Pinmemberazzawa2-Dec-06 21:13 
QuestionReceiving a file from a client which posts the file as multipart/formdata Pinmemberkuem09213-Nov-06 20:54 
QuestionRename File during / After Upload PinmemberRyan Powell3-Sep-06 2:56 
AnswerRe: Rename File during / After Upload Pinmembershillongite18-Sep-06 21:42 
AnswerRename File during / After Upload Solution Pinmember| kal9091@yahoo.com18-Oct-06 7:07 
Question'Default' specification can only be used on Property Get PinmemberElitedude20012-Sep-06 10:57 
QuestionSavse to the disk with MSAccess PinmemberRAMOREIRA17-Jan-06 5:09 
QuestionAnother functionality? Pinmembernelsonribeiro30-Oct-05 23:26 
GeneralPossible correction of download.asp file Pinmemberribeironl10-Oct-05 4:16 
NewsAdded GetText() function Pinsussbinarybasher10-Oct-05 0:30 
GeneralRe: Added GetText() function Pinmemberribeironl10-Oct-05 4:12 
AnswerRe: Added GetText() function Pinsussbinarybasher10-Oct-05 20:10 
AnswerRe: Added GetText() function Pinsussbinarybasher10-Oct-05 20:15 
QuestionCan&#180;t get some things to work... need help! Pinmembernelson ribeiro8-Oct-05 6:06 
General[Bug] On errror resume Next PinsussAlec_Eiffel_Jr7-Jun-05 0:17 
GeneralEven easier in .Net PinmemberAlrightyThen19-Nov-03 12:24 
GeneralRe: Even easier in .Net Pinmemberlimande25-Nov-03 3:37 
GeneralRe: Even easier in .Net PinmemberAlrightyThen25-Nov-03 7:46 
GeneralAccessing Form Object Pinmemberx-rom4-Oct-03 3:44 
GeneralRe: Accessing Form Object Pinmemberx-rom4-Oct-03 4:49 
Generalbug corrected,please check it !!!! Pinmemberroger_ca10-Jul-03 6:46 
GeneralWhere is the Bug? Getting the Filednames PinmemberAlex7319-Jun-03 2:28 
Generalupload files thru vbsUpload.asp doesn't work Pinmemberpg88739-Jun-03 20:39 
GeneralNo File Count PinmemberRo0ster18-Mar-03 8:58 
GeneralRe: No File Count Pinmemberroger_ca5-Jun-03 12:00 
GeneralLack of file error checking Pinmemberfaulk13-Jun-03 4:35 
GeneralRe: Lack of file error checking Pinmemberfaulk13-Jun-03 4:38 
GeneralRe: Lack of file error checking Pinmemberroger_ca10-Jul-03 6:32 
GeneralRe: Lack of file error checking Pinmemberlibarlin13-Oct-03 18:09 
QuestionHow to use multiple in select box PinsussAnonymous31-Jan-03 4:39 
AnswerRe: How to use multiple in select box PinsussAnonymous23-Aug-04 7:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.1 | Last Updated 30 May 2002
Article Copyright 2002 by THIRUMALAIKUMAR
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid