ASP,IIS,ADO,code,will,allow,form,based,file,u
Quick Search for:  in language:    
ASP,IIS,ADO,code,will,allow,form,based,file,u
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 118,709 lines
 Jobs: 148 postings

 
Sponsored by:

 

You are in:

 
Login


 

 


Latest Code Ticker for ASP/ VbScript.
Getting a random record from a table
By Serkan YOGURAN on 6/11


cool circle and line drawer
By john sheridan on 6/10


Click here to see a screenshot of this code!A Site Manager with Free Upload Functions (without payable components)
By Francisco J Riquelme on 6/10

(Screen Shot)

Simple Calculator
By Alistair Rodrigues on 6/9


Nutty Password
By jason mulryan on 6/9


Enviar email HTML ( send an email html )
By Javi P. D. on 6/9


Banner (rotacion de banners)
By Javi P. D. on 6/9


Paginar ( Paging )
By Javi P. D. on 6/9


Click here to see a screenshot of this code!Online photo catalogue VBScript
By Ivan Loire on 6/8

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Form Based File Upload Using Pure ASP

Print
Email
 
VB icon
Submitted on: 4/2/2001 9:45:09 PM
By: Karl P. Grear 
Level: Advanced
User Rating: By 45 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 49466 times.
 

(About the author)
 
     This code will allow you to do form based file uploads. It supports multiple files and uses only pure ASP. There are no components to install so it will work on any web server that supports ASP. Just paste this code into a text file and name it saveany.asp. I have tested it on IIS 4 and 5, with IE 4, IE 5 and Netscape 6. With this code you will be able to save a file in any directory that the anonymous account assigned to it (usually IUSER_machinename) has access to so be careful. I should note that the server needs ADO and the File System Object installed on it, but both of these are installed by default with ASP. Added ability to parse form data. Added ability to browse server folders for save location.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Form Based File Upload Using Pur
    '     e ASP
    ' Description:This code will allow you t
    '     o do form based file uploads. It support
    '     s multiple files and uses only pure ASP.
    '     There are no components to install so it
    '     will work on any web server that support
    '     s ASP. Just paste this code into a text 
    '     file and name it saveany.asp. I have tes
    '     ted it on IIS 4 and 5, with IE 4, IE 5 a
    '     nd Netscape 6. With this code you will b
    '     e able to save a file in any directory t
    '     hat the anonymous account assigned to it
    '     (usually IUSER_machinename) has access t
    '     o so be careful. I should note that the 
    '     server needs ADO and the File System Obj
    '     ect installed on it, but both of these a
    '     re installed by default with ASP.
    Added ability To parse form data.
    Added ability To browse server folders For save location.
    ' By: Karl P. Grear
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/xq/ASP/txtCode
    '     Id.6569/lngWId.4/qx/vb/scripts/ShowCode.
    '     htm    'for details.    '**************************************
    
    <%response.buffer=true
    Func = Request("Func")
    if isempty(Func) Then
    	Func = 1
    End if
    Select Case Func
    Case 1
    'You do not need to use this form to 
    'send your files.
    BrowseServer = Request.Form("BrowseServer")
    %>
    <H2>File Upload Form.</H2>
    	<TABLE>
    		<FORM ENCTYPE="multipart/form-data" ACTION="saveany.asp?func=2" METHOD=POST id=form1 name=form1>
    		<TR><TD><STRONG>Debug Options.</STRONG><BR></TD></TR>
    	 <TR><TD><INPUT NAME=Options TYPE=CheckBox Value='Raw'>Create Raw File<BR></TD></TR>
    		<TR><TD><INPUT NAME=Options TYPE=CheckBox Value='Boundry'>Create Boundry File<BR><BR></TD></TR>
    		<TR><TD><STRONG>Hit the [Browse Server] button to find the folder on the server to upload to.</STRONG><BR></TD></TR>
    		<TR><TD><INPUT NAME=ServerPath SIZE=30 TYPE=Text value='<%= BrowseServer %>'><INPUT type=button value="Browse Server" onclick="document.location='saveany.asp?func=3'" id=button1 name=button1><BR><BR></TD></TR>
    		<TR><TD><STRONG>Hit the [Browse] button to find the file on your computer.</STRONG><BR></TD></TR>
    		<TR><TD><INPUT NAME=File1 SIZE=30 TYPE=file><BR></TD></TR>
    		<TR><TD><INPUT NAME=File2 SIZE=30 TYPE=file><BR></TD></TR>
    		<TR><TD><INPUT NAME=File3 SIZE=30 TYPE=file><BR><BR></TD></TR>
    		<TR><TD><STRONG>Enter security password.</STRONG><BR></TD></TR>
    		<TR><TD><INPUT NAME=Password SIZE=30 TYPE=Text><BR></TD></TR>
    		<TR><TD align=left><INPUT name=submit type="submit" value="Upload File"><BR><BR></TD></TR>
    		<TR><TD>NOTE: Please be patient, you will not receive any notification until the file is completely transferred.<BR><BR></TD></TR>
    		</FORM>
    	</TABLE>
    <%
    Case 2
    Server.ScriptTimeout=300
    ForWriting = 2
    	adLongVarChar = 201
    	lngNumberUploaded = 0
    'Get binary data from form		
    	noBytes = Request.TotalBytes 
    	binData = Request.BinaryRead (noBytes)
    'convery the binary data to a string
    	Set RST = CreateObject("ADODB.Recordset")
    	LenBinary = LenB(binData)
    	if LenBinary > 0 Then
    		RST.Fields.Append "myBinary", adLongVarChar, LenBinary
    		RST.Open
    			RST.AddNew
    				RST("myBinary").AppendChunk BinData
    			RST.Update
    		strDataWhole = RST("myBinary")
    	End if
    	'get the boundry indicator
    		strBoundry = Request.ServerVariables ("HTTP_CONTENT_TYPE")
    		lngBoundryPos = instr(1,strBoundry,"boundary=") + 8 
    		strBoundry = "--" & right(strBoundry,len(strBoundry)-lngBoundryPos)
    	'ParseForm returns a dictionary object
    	'You can ParseForm any time after the
    	'Boundry indicator is set.
    	Set dPassword = ParseForm("Password") 
    	Set dOptions = ParseForm("Options")
    		'both of these are valid	
    		Response.Write ParseForm("Password").item(0) & "<BR>"
    		Response.write dPassword.item(0) & "<BR>"
    		SavePath = ParseForm("ServerPath").item(0)
    		if SavePath = "" or isempty(SavePath) Then
    			Response.Write "<H2> The following Error occured.</H2>"
    		Response.Write "You did Not enter a server path To save your file to."
    		Response.Write "<BR><BR>Hit the back button, make the needed corrections and resubmit your information."
    		Response.Write "<BR><BR><INPUT type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>"
    		Response.End 
    		End if
    		intCount = dOptions.count
    		if intCount > 0 Then
    			For x = 0 To intCount
    				Select Case dOptions.item(x) 
    					Case "Raw"
    						Raw = True
    					Case "Boundry"
    						Boundry = True
    				End Select
    			Next
    		Else
    			Raw = False
    			Boundry = False
    		End if	
    		if dPassword.item(0) <> "oktosend" Then
    				Response.Write "<H2> The following Error occured.</H2>"
    			Response.Write "The Password you entered is invalid."
    			Response.Write "<BR><BR>Hit the back button, make the needed corrections and resubmit your information."
    			Response.Write "<BR><BR><INPUT type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>"
    			Response.End 
    		End if
    	'Creates a raw data file For With all 
    'data sent. Uncomment for debuging.
    		if Raw Then
    		Set fso = CreateObject("Scripting.FileSystemObject")
    			Set f = fso.OpenTextFile(SavePath & "\raw.txt", ForWriting, True)
    			f.Write strDataWhole
    		Set f = nothing
    		Set fso = nothing
    		End if
    'Get first file boundry positions.
    lngCurrentBegin = instr(1,strDataWhole,strBoundry)
    lngCurrentEnd = instr(lngCurrentBegin + 1,strDataWhole,strBoundry) - 1
    countloop = 0
    Do While lngCurrentEnd > 0
    'Get the data between current boundry 
    'and remove it from the whole.
    strData = mid(strDataWhole,lngCurrentBegin, (lngCurrentEnd - lngCurrentBegin) + 1)
    'Remove the file data from the whole	
    		'strDataWhole = replace(strDataWhole,strData,"")
    'Get the full path of the current file.
    	lngBeginFileName = instr(1,strdata,"filename=") + 10
    	lngEndFileName = instr(lngBeginFileName,strData,chr(34)) 
    'Make sure they selected at least one 
    'file.	
    	if lngBeginFileName = lngEndFileName and lngNumberUploaded = 0 Then
    			Response.Write "<H2> The following Error occured.</H2>"
    			Response.Write "You must Select at least one file To upload"
    			Response.Write "<BR><BR>Hit the back button, make the needed corrections and resubmit your information."
    			response.Write "<BR><BR><INPUT type='button' onclick='history.go(-1)' value='<< Back' id='button'1 name='button'1>"
    			Response.End 
    	End if
    'There could be one or more empty file b
    '     
    'oxes.	
    	if lngBeginFileName <> lngEndFileName and lngBeginFileName - 10 <> 0 Then
    		strFilename = mid(strData,lngBeginFileName,lngEndFileName - lngBeginFileName)
    'Creates a raw data file with data 
    'between current boundrys. Uncomment 
    'for debuging.
    
    		if Boundry Then
    		Set fso = CreateObject("Scripting.FileSystemObject")
    		Set f = fso.OpenTextFile(SavePath & "\raw_" & lngNumberUploaded & ".txt", ForWriting, True)
    			f.Write strData
    		Set f = nothing
    		Set fso = nothing
    		End if
    'Loose the path information and keep 
    'just the file name.	
    		tmpLng = instr(1,strFilename,"\")
    		Do While tmpLng > 0
    			PrevPos = tmpLng
    			tmpLng = instr(PrevPos + 1,strFilename,"\")
    		Loop
    		FileName = right(strFilename,len(strFileName) - PrevPos)
    'Get the begining position of the file 
    'data sent.
    'if the file type is registered with 
    'the browser then there will be a 
    'Content-Type
    		lngCT = instr(1,strData,"Content-Type:")
    		if lngCT > 0 Then
    			lngBeginPos = instr(lngCT,strData,chr(13) & chr(10)) + 4
    		Else
    			lngBeginPos = lngEndFileName
    		End if
    'Get the ending position of the file 
    'data sent.
    		lngEndPos = len(strData) 
    'Calculate the file size.	
    		lngDataLenth = (lngEndPos - lngBeginPos) -1
    'Get the file data	
    		strFileData = mid(strData,lngBeginPos,lngDataLenth)
    'Create the file.	
    		Set fso = CreateObject("Scripting.FileSystemObject")
    		Set f = fso.OpenTextFile(SavePath & "\" & FileName, ForWriting, True)
    		f.Write strFileData
    		Set f = nothing
    		Set fso = nothing
    			if lngNumberUploaded = 0 Then
    				Response.Write "<STRONG>Saving Files...</STRONG><BR><BR>"
    			End if
    		Response.Write SavePath & "\" & FileName & "<BR>"
    		lngNumberUploaded = lngNumberUploaded + 1
    	End if
    'Get then next boundry postitions if 
    'any.
    	lngCurrentBegin = lngCurrentEnd
    	lngCurrentEnd = instr(lngCurrentBegin + 9 ,strDataWhole,strBoundry) - 1
    	'Prevents infinate loop.
    		countloop = countloop + 1
    		if countloop = 100 Then
    			Response.Write "looped 100 times terminating script!"
    			Response.End 
    		End if
    loop
    		Response.Write "<STRONG>" & lngNumberUploaded & " File(s) Uploaded</STRONG>"
    		Response.Write "<BR><BR><INPUT type='button' onclick='document.location=" & chr(34) & "saveany.asp" & chr(34) & "' value='<< Back to Listings' id='button'1 name='button'1>"	 						
    	Case 3
    		'get prev path if any
    		path = Request.QueryString("Path")
    		'if Not assign one
    		if path = "" or isempty(path) Then
    			path = "c:\inetpub"
    		End if
    		'create filesystemobject
    		Set fso = CreateObject("Scripting.FileSystemObject")
    		'get a folder object
    		Set f = fso.GetFolder(path)
    		path = f.path
    		'limit access To hard drive
    		if lcase(left(path,10)) <> "c:\inetpub" Then
    			path = "C:\Inetpub"
    			Set f = fso.GetFolder(path)
    			path = f.path
    		End if
    		Response.Write "<H2>Server Browse Form.</H2>"	
    		Response.Write "<FORM ACTION='saveany.asp?func=1' METHOD=POST>"
    		Response.Write "<TABLE width=400 border=1 cellpadding=0 cellspacing=1>" & vbcrlf
    		Response.Write "<TR><TH colspan=2>" & path & "</TH></TR>"
    		Response.Write "<TR><TD colspan=2 align=left><A href='saveany.asp?func=3&path;=" & path & "\..'><STRONG>Parent ..</STRONG></A></TD></TR>" & vbcrlf
    		'get subfolders collection
    		Set fc = f.subfolders
    		'enum subfolders 
    		For Each folder In fc
    			Response.Write "<TR><TD align=left><INPUT NAME=BrowseServer TYPE=CheckBox Value='" & folder.path & "'></TD><TD style='padding-left: 20px;' align=left><A href='saveany.asp?func=3&path;=" & folder.path & "'>" & folder.name & "</A></TD></TR>" & vbcrlf
    		Next
    		'if there is a folder display the Select folder button
    			if fc.count > 0 Then
    				Response.Write "<TR><TD align=left colspan=2><BR><INPUT name=submit type='submit' value='Select Folder'></TD></TR>"
    			End if
    			Response.Write"<TR><TD colspan=2><INPUT name=cancel type='Button' value='Cancel' onclick=document.location='saveany.asp?func=1'></TD></TR>"
    		Response.Write "</TABLE>" & vbcrlf
    		Response.Write "</FORM>"
    End Select
    %>
    </BODY>
    </HTML>
    <SCRIPT LANGUAGE=vbscript RUNAT=Server>
    	function ParseForm(strFieldName)
    		Set strFormData = CreateObject("Scripting.Dictionary")
    		lngCount = -1
    		'Try To find the Field
    		lngNamePos = instr(1,strDataWhole,"name=" & chr(34) & strFieldName & chr(34))
    		'Parse through data In search of fields
    			Do While lngNamePos <> 0
    				lngCount = lngCount + 1
    				lngBeginFieldData = instr(lngNamePos,strDataWhole,vbcrlf & vbcrlf)+4
    				lngEndFieldData = instr(lngBeginFieldData,strDataWhole,vbcrlf)
    				strFormData.Add lngCount, mid(strDataWhole,lngBeginFieldData,lngEndFieldData-lngBeginFieldData)
    				lngNamePos = instr(lngEndFieldData,strDataWhole,"name=" & chr(34) & strFieldName & chr(34))
    			Loop
    			Set ParseForm = strFormData
    	End function
    </SCRIPT>

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
4/4/2001 5:24:30 PM:RObot X5
This Rocks ..... 
Keep up the good 
work....
I am kinda pissed I needed 
this about a year a go .... 
I had to 
make my own dll and that 
sucked.....
once again You Rock!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/10/2001 3:13:33 AM:Sam Moses
Wait a minute... a free asp uploader 
that actually works??? Man, I wish I 
would have had this three months ago. 
Great scripting dude.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/19/2001 8:56:43 AM:Kaustav Acharya
Awesome Job! 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/15/2001 5:04:12 PM:Radames
Gracias, muchas gracias!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/13/2001 1:23:52 AM:Sam Moses
As it turns out, I actually have a use 
for this wonderful script again. Is 
there a way to restrict access to gif 
or jpg on the server side rather than 
the client side. I wrote a javascript 
to do that on the client side, but it 
can be worked around. Any ideas?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/14/2001 2:33:03 PM:Rodrigo Fiche
Very good!!!
Thanks, Karl P. Grear...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/15/2001 10:58:23 PM:Karl
Gary
I have had no trouble, althoght I 
admit I use IE 5.5 and IIS 5.0.
You 
may try updating your browser and see 
if that helps :)
Karl
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/15/2001 11:02:59 PM:Karl P. Grear
David,
Yes you must.  Once you get 
your first form or querystring value 
you can no longer request.binaryread 
and visa versa.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/15/2001 11:08:38 PM:Karl P. Grear
Sam and Richard,
Yes you can filter 
by file type.
One easy way is to check 
the file extension before you save the 
file.
Karl
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/15/2001 11:11:08 PM:Karl P. Grear
I just want to thank everyone for the 
great response and all the votes.
I am 
glad that so many people are finding 
this code usefull.
Karl
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/19/2001 12:38:26 PM:Juls
Hi, Thanks for posting the code.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/20/2001 6:00:38 AM:Jason L
This code is useful but i need more 
functions that just uploading. Could 
you add some coding that will add the 
file name into database and another 
page to display the graphics uploaded ? 
Thank you. 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/20/2001 11:45:55 PM:Karl P. Grear
Andy
Hmmm.... What browser are you 
using?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/22/2001 2:43:59 PM:Andy
I'm using IE 5.5, but it also has to 
work in Netscape 4.? and above.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/27/2001 1:24:41 PM:Eric
Andy...
I was having the same 
problem.  Somehow, my submit button was 
given name and id attributes by my 
editor without my knowing.  This was 
causing the filename 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/29/2001 3:16:02 PM:Karl P. Grear
Ok,
I added support to get form data, 
which eliminates the submit button name 
issue.
Thanks for your votes, 
support, and input. :)
Karl
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/30/2001 10:00:27 AM:fadhil
i want to ask about the 
password...there is error massage 
appear. (the password u enterd is 
invalid)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/6/2001 3:45:28 AM:gopal
hi, thanks for nice script.
 when i 
upload  the form with a selectbox of 
multiple selection i cannot get more 
than one value in the 
Parseform().
advance thanks for any 
help
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/9/2001 6:11:31 AM:Clifford
Fantastic man, keep on going. I hope 
you win this month.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/9/2001 11:51:21 AM:Karl P. Grear
Another update,
you can now get all 
the values of form items with the same 
name.  The new code returns a 
dictionary object with the value(s) 
populated for the form item.
Hope 
this helps :)
Karl
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/9/2001 12:15:21 PM:Karl P. Grear
Note from Author:
I wrote this 
script because I spent hour after hour 
searching the web for it when I needed 
it, and all I found was sites that 
wanted me to pay for it.  Frustrated 
and more then a little disgusted I 
decided that I would figure out how to 
do it my self.  The script above is the 
results of my effort and the ideas and 
input of those who have used and voted 
for it.  I would like to again thank 
everyone for his and her votes and 
input. 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/13/2001 1:42:01 PM:dan
Wondering is there a way to direct 
where the files will be upload as well 
as have it viewable on a webpage?  I 
will be uploading 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/25/2001 11:36:27 AM:Rally
I having problem on password. Could you 
help me resolve this issue.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/30/2001 7:12:35 AM:KodeKrash
I was just reading over some of the 
posts here and wanted to point out that 
different Scripting Engine versions 
will cause some of these errors. I 
assume that Karl wrote this running at 
least VBScript 5.0 on his server. If 
you are not sure what Scripting Engine 
you are running, just grab the 
ScriptEngineVersion checker from 
www.intelidev.com. Other than that 
Karl, great job. :o)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/30/2001 9:15:44 AM:Peter
Great job ... and it works!
I found 
only a small mistake 
...
	<TR><TD><STRONG>Enter security 
password.<STRONG><BR></TD></TR>
The 
/strong is wrong...
Bye and thanx a lot
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/30/2001 9:58:53 AM:Karl P. Grear
Thanks to Perer for pointing out the 
HTML error.  Thanks to KodeKrash for 
the heads up on scripting engine 
:)
Karl
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/3/2001 1:29:29 PM:Kas
I am receiving an error about password 
and I have entered every password that 
exists and it still give me the error. 
Could you please help I really need 
this. 
Thanx
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/7/2001 10:05:42 AM:Sean Street
Excellent.  Worked like a gem.  Now to 
take it apart and figure out how it 
works.  Thanks for sharing.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/11/2001 9:17:51 AM:Deryck
I need the password and to know how to 
add other info(title, desc., etc) into 
an MS Access2000 DB and make a web page 
post that info, along with a link to 
the file so a user can download it at 
the same time.  And if it is and image 
how do I have it posted to the page one 
after another automaticly?  thanx
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/11/2001 9:20:32 AM:Deryck
The password is::
OkToSend
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/11/2001 10:45:29 PM:Deryck
That was a clearer version of what I 
already posted.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/14/2001 12:48:30 PM:Joel
Thanks man, great code... very good 
work...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/20/2001 12:14:59 PM:cody
Nice work!
But how to upload files to 
a "user/password" protected directory 
using ASP?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/4/2001 7:56:42 AM:Snakefighter
May be it works :)
But as it is said 
previously how can we upload file if's 
password 
protected.
snakefighter99@hotmail.com
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/4/2001 10:34:12 AM:Karl
By password-protected directory, I 
assume you mean a directory that the 
default anonymous account does not have 
access to.  Here are a few solutions 
and a few suggestions.
1. Change the 
default anonymous account for 
saveany.asp to one that does have 
access to the directory in question.  
Store a password in a text or database 
file saved outside the web root, 
preventing it from being downloaded.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/4/2001 10:35:38 AM:Karl P. Grear
2. Give the default anonymous account 
for saveany.asp, rights to the 
directory in question.  Store a 
password in a text or database file 
saved outside the web root, preventing 
it from being downloaded
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/4/2001 10:36:42 AM:Karl P. Grear
3. Disable anonymous access to the 
saveany.asp file in IIS.  This will 
prompt the user to log on to the server 
with a valid NT Username and Password.  
In order to authenticate the user must 
log on to an account, which has access 
to the saveany.asp file and/or 
directory.  In order to upload the 
account must have ‘change’ rights to 
the upload directory in question. 
4. Force the user to log on with a 
valid NT Username and Account, using 
the following script.  In order to 
authenticate the user must log on to an 
account, which has access to the 
saveany.asp file and/or directory.  In 
order to upload the account must have 
‘change’ rights to the upload directory 
in question.
<%
if 
Request.ServerVariables("LOGON_USER") = 
"" then
   Response.Status="401 Access 
Denied"
end if  
%>
NOTE: Method 
2 is the preferred method .
Good 
Luck.  And thanks for voting 
:)
Karl
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/10/2001 11:49:12 AM:Chris
I'm using Win2K and IE 6.0.  Every time 
I try to upload any file, it says 
Permission denied
/saveany.asp, line 
275. I've tried giving every permission 
i know of and I still can't get it to 
work.  Any ideas would be appriciated.  
Thank you
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/12/2001 10:11:10 AM:MAKO
How can I Upload a file when i know 
only the Url of the server, and I can't 
navigate it's folders? I try to put the 
URL in the server Path But It doesn't 
work. (sorry for the bad english), 
thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/12/2001 10:15:16 AM:MAKO
I can't upload any file if i try to put 
the URL of the server. I can't know the 
path of the machine and i can't 
navigate it's folders. What can i 
do?
(sorry for the bad english), 
Thanks MAKO
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/30/2001 9:02:18 PM:Sam Moses
I love the new server browser feature. 
Is there a way to get it to upload more 
than three files at once?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/2/2001 2:23:01 AM:robinash
Is there any way to upload multiple 
files without having to have x amount 
of INPUT NAME=File1 SIZE=30 
TYPE=file> 
???????   I can't find the 
solution...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/4/2001 5:36:06 AM:noel rodrigues
Hello Karl, wonderful job by you. 
I 
need a help, i have the following 
code
<%
  formsize = 
request.totalbytes
  formdata = 
request.binaryread (formsize)
response.binarywrite 
formdata
%>
now how do i write the 
contents of 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/4/2001 5:54:51 AM:noel
Karl please help,
my code to receive 
file is :
  formsize = 
request.totalbytes
  formdata = 
request.binaryread(formsize)
response.binarywrite formdata
now i 
want to write it to a text file & later 
read it like binary read. How can I do? 
Urgent Please help. Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/9/2001 7:39:21 AM:Albertos
here u have a very good code... but 
there is a small prob...if u have a 
field in your form and the text there 
is not in english (eg. greek 
characters) then the parseform(
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/9/2001 8:01:22 AM:sfong15@yahoo.com
Very good work.   Some minor comments.  
(1)change Type=
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/10/2001 7:08:30 PM:Doug
Thanks a lot for the posting!  I'm 
having a small problem, though, and was 
hoping for some help...
After 
choosing a directory on the server, and 
a file to upload, as well as entering 
the password I submit and get the 
following error:
Error 
Type:
Microsoft VBScript runtime 
(0x800A01B6)
Object doesn't support 
this property or method: 
'ForWriting'
/samples/test/saveany.asp,
 line 81
Thanks a lot in 
advance!
Doug
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/10/2001 7:24:07 PM:Doug
duh.  Please excuse the last 
post...
WORKS GREAT!
THANKS FOR 
POSTING!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/11/2001 4:12:35 PM:alan
the upload file size is not same as the 
origin, plz help
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/11/2001 4:14:22 PM:ALAN
Hi,
the script is so good. However, 
after i upload the files to the folder, 
the files size is not same as the 
original once plz help
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/23/2001 1:58:56 AM:Waqas
Hi Guys,
I am facing this problem,
it 
is working fine on my local server, but 
when I host it at my virtual webserver, 
it gives the following error: Can 
anyone advise me, what's the problem 
is. Is it a matter of rights or ...??? 
an immediate reply shall be very 
highly appreciated. kind regards,
- 
waqas
urf3@yahoo.com
Microsoft 
VBScript runtime error '800a01b6' 
Object doesn't support this 
property or method: 
'Request.TotalBytes' 
/verizon/outputFile.asp, line 16 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/23/2001 1:04:29 PM:Kenneth
Will this code be able to allow my 
users to upload MP3 file's also?  If 
not then do you know where I can find 
one? 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/23/2001 1:07:01 PM:Kenneth
Will this code allow my users to upload 
mp3, jpg, and gif files to my server?  
If not all, then do you know where I 
can find one?
Thanks 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/1/2001 4:05:29 PM:Kenneth
Hello I tried to upload a file using 
the password "OkToSend" but I kept 
getting the following response:  
Invalid Password
Is there another 
password I could use?
Also, Is there a 
way I can make the "Browse Server" 
section automatically default to a 
specific folder so that my users will 
not have to input anything in that 
section?
Thanks for your help.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/9/2001 11:17:43 AM:Brandon
Hi, Thanks for taking the time to come 
up with this code.  But I seem to have 
a slight problem, I've copied and 
pasted the code, but for some reason I 
keep getting the following error when I 
click the upload file:
Microsoft 
VBScript runtime error '800a01b6' 
Object doesn't support this 
property or method: 'Append' 
/ccsys/uploader.asp, line 101 
Any idea what causes 
this?
Thanks,
Brandon.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/17/2001 1:46:23 AM:Chris
This was a great help in my coding 
endeavors.  I've been able to take the 
code you supplied here and do some 
pretty amazing stuff with it.  I've 
incorporated it into creating 
completely dynamic file listings for 
application uploads and downloads and I 
never have to leave the original web 
page.
This was just what the doctor 
ordered.
Great job...!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/27/2001 7:09:19 PM:stanley
the code is fantactic, but i am running 
into problems when i submit , even with 
the proper password 'oktosend' . This 
is the error message:
 Microsoft 
VBScript runtime error '800a0034' 
Bad file name or number 
/saveany.asp, line 403. Does anyone 
have any ideas. It seems that there has 
been similar problems discussed in the 
Feedback log. 
please help me use 
your great code
stanley
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/28/2001 10:44:21 PM:hendra
the code is fantactic, but i am running 
into problems when i submit , even 
with 
the proper password 'oktosend' . 
This 
is the error message:
Microsoft 
VBScript runtime error 
'800a0034' 
Bad file name or 
number 
/saveany.asp, line 403. 
Does anyone 
have any ideas. It seems 
that there has 
been similar problems 
discussed in the 
Feedback log. 
please help me use 
your great 
code
hendra
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/28/2001 10:49:04 PM:hens
my problem same with above reason
whwn 
i filled my paasword t.s response is 
:
Microsoft 
VBScript runtime error 
'800a0034' 
Bad file name or number 
/saveany.asp, line 403
please help 
me....
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/30/2001 5:02:48 PM:jay
this code is spectacular.  thank you so 
much for sharing.  you have no idea 
what a headache it has been trying to 
figure the code for uploading without 
using a COM object... sooooo, this code 
is most appreciated!  Great JOB 
A+++++
Jay
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/12/2001 11:40:03 AM:Brent
Thanks for some excellent code. I've 
been trying to modify it to have some 
type of an alert message if a file with 
the same name exists.
Has anyone 
been able to do this?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/15/2002 4:50:46 PM:Mirjana Jovanovic
Wonderful code. Thanks for posting 
it.
It would be good if the file 
renaming was provided as 
well.
Thanks again
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/18/2002 4:58:23 PM:Tanya
Thank you, thank you, thank you!  I've 
been looking for a file upload script 
for a long time.  Thank you for sharing 
your work with us!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/22/2002 2:42:41 PM:Robert
Thanks a ga-billion for this code!
Can 
anyone help me with examples of how to 
get form data into the database as well 
with out using request.form. You have 
to convert form data to ASCII?
Any 
help would be appreciated..
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/30/2002 1:20:45 PM:Kathy
good code thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/22/2002 10:11:19 AM:Paul Mather
Nice job.  Works great!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/28/2002 11:32:44 AM:Frank
WOW!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/6/2002 12:56:16 PM:Chris
This code is excellent.  With some 
tweaking and some Javascript I have 
created a look alike of Microsoft's 
Sharepoint Upload.htm.  This doesn't 
require the WebBot and works just as 
well.  Additionally mine now has a 
Comment field that takes the 
information and adds it to a SQL 
DB.
Thanks again...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/6/2002 4:35:24 PM:Dan W
Nice work, thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/7/2002 5:17:17 AM:deejay
Just great code!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/11/2002 4:41:44 PM:Tony
this is great! can you limit the file 
extension upload? ex: .jpg .gif only? 
don't let them upload .exe or .dll 
files to the website ... waiting for 
your code!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/11/2002 9:08:25 PM:TomGlen
1st Karl this is great work. Thank you 
for your willingness to share this with 
everyone.
Regarding file extension 
blocking, I got something to work by 
parsing the extension from the filename 
variable and then putting a if 
statement that controls whether the 
block of code that writes the file gets 
executed.
Does anyone know how to 
file the file size?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/15/2002 8:15:17 PM:Tony
can you send the " a if 
statement 
that controls " for me at 
sharky626@yahoo.com? I not know much 
about asp and my english real suk :( 
thanks alot! about filter the file 
side, look in the saveany.asp for this  
   Server.ScriptTimeout=300.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/17/2002 9:07:05 PM:Tony
any know how to limit the file 
extension? help me with the code please!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/18/2002 5:30:25 AM:Krishna
Ur asp upload is fabulous but i just 
want to ask u something more out of ur 
code like when u upload the file if 
there is a file with the same name , is 
it possible to give an alert message 
and asking them to give a new name for 
the file which they r 
uploading.
cheers
Krishna
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/19/2002 4:57:08 PM:Don
When I change the directory from the 
default -- c:\inetpub to my 
directory--d:\web it's showing the new 
directory but I can't browse through 
it. I added IUSER to this folder for 
access but nothing. Any thoughts?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/19/2002 5:06:05 PM:don
nevermind I got it.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/26/2002 5:20:59 PM:Tyson
Thanks for the great code. I had this 
working in 60 seconds.  I appreciate 
your efforts to share code with other 
users free of charge.  This really 
helps us learn and accomplish our daily 
challenges.  THANKS AGAIN!!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/2/2002 9:07:45 AM:Mike
After reading the comments I am certain 
that this code works. I have an 
absolute need for this code, but am 
quite new to ASP. I use the free 
services of Brinkster.com to host my 
ASP site, after pasting this code in I 
got nothing, are there places in the 
code I need to change?
Thankyou for 
your anticipated help.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/2/2002 9:38:12 AM:mike
I would like to append to my last post. 
I still need assistance, but I at least 
have the form up now. I had to set the 
server timeout to 60 as this is the max 
brinkster will allow. The problem now 
is that when I hit the server browse 
button I get the "page cant be viewed" 
Message. Also when I enter my password, 
I get an invalid password message, 
although I know I am entering the 
correct password for my account.
I am 
very excited to put this code to use, 
with a little guidance I'm hoping i'll 
be able to.
Thanks!
-Mike
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/3/2002 1:24:28 PM:Tony
any one can write for me a blocking 
file extension to put in this script? 
thanks a lot man!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/4/2002 10:37:33 PM:Bruce
To browse the directory of a remote 
server where you don't know the 
path...change the code in function 3 to 
path = server.mapPath(".").  Now it 
will work :)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/11/2002 5:58:33 AM:John
I am beginner of ASP and I would like 
to know how to get the name of the 
file(s) that we had been uploaded. Any 
ideas for me.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/12/2002 9:31:44 AM:Ed
Really like the code, feel like I am 
missing something simple but I keep 
getting a Type Mismatch :'ParseForm'.  
Please help when possible
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/12/2002 9:35:22 AM:Ed
Nevermind, I was incorrect on my end, 
you code works great!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/16/2002 8:34:41 PM:Yuval
I get an error 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/16/2002 8:37:04 PM:Yuval
I get an error "the page cannot be 
Found" (...asp?func=2). Help.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/1/2002 1:16:18 PM:Arun Kumar
Hi karl 
you have written a fantastic 
code
and you have become my 
inspiration figure
i tried to reframe 
you code into two asp pages one.asp and 
two.asp
but got this error
Error 
Type:
Microsoft VBScript runtime 
(0x800A0005)
Invalid procedure call or 
argument: 'mid'
/asp/testqp/two.asp, 
line 36
i can't paste code here due to 
area constrin and unfortunately i was 
not able to sign in, to email you also, 
can any body tell whats karl's mail 
id 
karl....karl i need you help very 
much 
please mail me at 
arunkw@yahoo.com 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/7/2002 12:22:17 AM:Pearl
This is a great code truely beyond my 
capabilities...... maybe that's why I 
can't upload anything other than text 
files... hmm...
Can anyone help me 
with that?  The file goes to the server 
but the contents don't show up.
Any 
help would be greatly appreciated.  
Thank you.
pearl@grandtech.com.tw
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/7/2002 12:23:05 AM:Pearl
This is a great code truely beyond my 
capabilities...... maybe that's why I 
can't upload anything other than text 
files... hmm...
Can anyone help me 
with that?  The file goes to the server 
but the contents don't show up.
Any 
help would be greatly appreciated.  
Thank you.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.