COM,Allows,upload,multiple,files,fields,witho
Quick Search for:  in language:    
COM,Allows,upload,multiple,files,fields,witho
   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



 
 
   

Upload Files Without COM

Print
Email
 
winzip icon
Submitted on: 1/13/2001 4:56:05 PM
By: Lewis Moten  
Level: Intermediate
User Rating: By 7 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 23140 times.
 

(About the author)
 
     Allows you to upload multiple files and fields without purchasing or registering COM objects. Great for shared hosts that frown upon 3rd Party com objects or charge an arm and a leg for them. This version uses Classes rather then the dictionary object that I have seem most other people use. Dictionary Objects seem to be flakey with more problems. I have added examples of how to upload a file to a database and the file system. A file is also included that retreives the file from the database.

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzipto decompress it.

Virus note:All files are scanned once-a-day by Planet Source Code for viruses,but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:
1)Re-scan downloaded files using your personal virus checker before using it.
2)NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
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.


Other 82 submission(s) by this author

 

 
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 Intermediate 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
1/14/2001 3:29:30 PM:RR_Pilot
do these files actually get uploaded if 
they do where does it save to? or does 
it just get info?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/20/2001 3:35:13 AM:elaroy
I got a nice table but how do I get it 
to save the uploaded file data as a 
file on the server?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/23/2001 2:09:13 PM:Lewis Moten
Ok, I've added some extra files that 
show you how to save your files to a 
database and the file system.  A sample 
database is included so this should 
work rite out of the box.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/31/2001 5:30:29 PM:Joel Wyrick
Great code.  This worked right out of 
the box and it was just what I was 
looking for!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/6/2001 2:20:59 PM:Stephen
Very Good code, Great for automating my 
site so that my boss can even update it 
now, thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/19/2001 11:44:00 AM:Tommy
Hi !!
I having problems getting the 
File system upload to work When i push 
the upload button i get a page can`t be 
displad message !
What is the problem
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/19/2001 11:42:34 PM:Lewis Moten
Page can't be displayed?  Hmm.. Without 
more details, my guess would be that an 
error had occured within the code.  As 
to the reason, my best guess is that 
the Internet User account does not have 
access to write files to the directory 
that you are uploading files to.  Find 
the directory in your file system and 
view its properties.  Click on the 
security tab.  Click on the button 
[Add...].  Search for a user beginning 
with 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/19/2001 11:44:24 PM:Lewis Moten
beginning with "IUSER_" and Click [add] 
so they appear in the list  of users 
who have permission to access the 
directory below.  Click [OK].  Make 
sure that they have "Write" 
permissions.  You may also want to 
allow them "Modify" permissions as 
well.  I hope this helps.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/27/2001 9:21:33 AM:Soffipropp
Looks good. I have one problem though, 
I can´t open the database, why??
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/21/2001 4:38:07 PM:wesley
is there a readme file on how to set it 
up?
1)I simply have IIS 4, is that 
enough?
2)I tried it but it returns an 
error
: 'Fields(...).AppendChunk' 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/21/2001 4:40:15 PM:wesley
1)is there a readme file to 
setup?
2)what other server requirement 
is there?? 3rd party programs? I simply 
have IIS 4
3)I tried upload to a 
database but I got this error
: 
'Fields(...).AppendChunk' 
thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/2/2001 1:23:38 PM:Mike
Although this code works wonderfully, 
the problem we're encountering (with 
our COM solution, and this code) is 
that we can't seem to open a file on a 
remote machine from IIS.  FSO fails, 
our COM attempts have failed, etc.  
Uploading the file to the web server 
works fine.  Uploading it to a share on 
the SQL server fails.  Outside of IIS, 
the file can copy over fine... it is 
definately limited to IIS (we've even 
had our 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/2/2001 1:24:33 PM:Mike Knowles
(we've even had our "outside-of-IIS" 
copy app impersonate the IIS Anonymous 
account to check to see if it was a 
permissions issue - even though the 
share is world writable)
Any 
thoughts?  Have you tested this code 
against uploading to a remote 
machine?
(nice code, otherwise!)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/23/2001 4:34:48 AM:lost_soul
i can't upload jpg files.
BTW:
can 
anyone upload files larger than 
150++kb????
i'm having error with 
this.
anyone can solve this error?
is 
there a script time 
out???/
thanks..........
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/2/2001 11:37:12 AM:Bill Kehn
I keep getting this error with the file 
system upload.  All permissions are 
good.  BTW database upload works great.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/2/2001 11:39:00 AM:Bill Kehn
I'm not sure if I included the error in 
my last post but here it is.
Error 
Type:
Microsoft VBScript compilation 
(0x800A0411)
Name 
redefined
/ToFileSystem.asp, line 11, 
column 4
Dim sPath
---^
Thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/11/2001 6:07:14 PM:Brian Conner
I need a script that will allow me to 
upload files up to 5 Mb. Is this 
possible with this script or am I going 
to get timeouts?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/23/2001 10:37:24 AM:JF
I get this error when I click on the 
UPLOAD 
button:
***********
Microsoft 
VBScript compilation error '800a0400' 
Expected statement 
/Office/bulletinboard/upload2/clsUpl
oad.asp, line 11 
End 
Class
^
*********
What did I miss?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/4/2001 4:38:41 AM:Jose Andres
I am trying to find an Upload solution 
than not uses the 100% of CPU of the 
server when uploads a big file. How can 
I solve this problem? I have passed  
the last Service Packs, and I think 
that my IIS is well configured.
Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 3:33:20 AM:Nicholas Hurt
Great Code! But how would I ensure that 
the files uploaded can only be of the 
.gif or .jpg type?   Is there some 
parameter line I can use? Thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 9:57:49 AM:Lewis Moten
ack!  soo many people responding.  I'll 
try to answer your questions, but I may 
be a little slow.  To tell if the file 
is a JPG or GIF - look at the 
ContentType.  I believe they are 
image/jpg and image/gif.  Also, Netscap 
content types might be a little 
different then Internet Explorers, so 
you'll have to check them out and 
determine wich one is witch.  You can 
also look at the last 3 characters of 
the file name.  (Obviously they are 
"GIF" and "JPG").  If you really want 
to get advanced, You can do a search on 
the binary data.  the first three 
letters of the GIF's should be GIF - 
remember to search via. binary (ASCII)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 9:59:46 AM:Lewis Moten
Upload without using CPU 100%?  You 
might want to look into professional 
components for that one.  If you are 
working on a very large solution, you 
may want to consider building your own 
that will work with COM+ so that 
another machine will handle the parsing 
of the binary data.  Other then that - 
I'm at a loss for a solution to the 
problem without further investigation.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 10:01:21 AM:Lewis Moten
Answer to "JF"'s problem - Expected 
statement.  Something tells me that you 
opened an "If" statment and didn't 
close it somewhere  ... before you 
included my class in your web page.  
Just look through your code and make 
sure the syntax is correct.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 10:04:00 AM:Lewis Moten
Brian Conner: In order to allow large 
uploads, you need to setup the 
Server.ScriptTimeout to allow more time 
before the page dies.  This is measured 
in seconds - and I believe it is setup 
to 2 minutes (120 seconds).  Just set 
it up to Server.ScriptTimeout = Minutes 
* 60
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 10:05:54 AM:Lewis Moten
Bill Kenn: I accidentally declared the 
variable twice.  Just take out line 11. 
 I'll have to look at the code tonight 
to see if I fixed this problem before.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 10:09:53 AM:Lewis Moten
Mike Knowles: What i'm gathering is 
that you have a mapped network drive 
that you wish to save a file to.  If 
this is the case, then the problem is 
this - The remote computer is not 
comprimizing the web servers local 
Internet User account.  One idea i 
would try is adding the internet user 
to the remote server (Remember, this 
account name has the machine name 
within its username).  If that doesn't 
work, I would then check to see if your 
COM object that you were trying 
supports impersinating NT User 
accounts.  If so, the solution is easy. 
 Just make it pretend it is a user on 
the remote machine.  Hopefully that 
helps solve the problem.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/8/2001 10:13:27 AM:Lewis Moten
wesley: there are not read me files 
other then the feed back you see here 
and my email address.  I am uncertain 
as to the problem with the 
.AppendChunk.  One idea may be that 
your file is just too large and may 
need to be broken appart for multiple 
Append Chunks.  Another is that perhaps 
your version of ADO doesn't support 
this method.  I havn't tested this on 
other platforms besides Win2K with ADO 
2.6.  The way I build most of my code 
here is to support the idea that you 
don't have to install anything more 
then the basic web server setup in 
order to use my code.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/19/2001 11:36:25 AM:Seamus McConville
The code works well. If I am uploading 
a large file is it possible to display 
a progess bar to give the user a rough 
indication of how long it would take. 
Or maybe you could suggest a site where 
I could find this?
Thanks.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/3/2001 11:07:05 AM:Brent
Nice script!  Can't upload anything 
above 150K though, even though I've set 
Server.ScriptTimeout to about 10 
minutes.  Noticed someone else above 
was having the same problem.  150K 
seems about the limit for me to.  
Anybody have any ideas?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/3/2001 11:11:08 AM:lewis@moten.com
Yes, I'm having the same problems 
myself.  I don't know why though.  I'll 
have to dig into the code when I get 
some free time.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/19/2001 2:35:28 PM:Jenz
Hello!
HAD the same problem as 
stated above,
but I increased the 
ScriptTimeout to 3600, after that it 
worked fine.
The ScriptTimeOut is 
set in seconds.
Running on NT 
4.0/IIS 4.0 SP 5
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/19/2001 2:41:51 PM:Jenz
Did I mention that I uploaded a picture 
that was 5'576'202 bytes?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/3/2001 11:52:43 AM:Steve
Great script.  I have a really novice 
question.  I need to increase the 
ScriptTimeout so that I can upload 
larger files, but don't know where to 
find that setting.  Can someone let me 
know where to find it.  Thanks!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/8/2001 11:43:34 AM:cgarnir
is it possible to insert a session 
variable in to the Server.MapPath 
string
i want to insert a subdirectory 
at runtime.
i know that the category 
directory exist so i can include this, 
but what about a subdirectory we only 
know from a session variable?
' 
Save the file to the file system
Set 
fso = CreateObject(
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/8/2001 11:45:12 AM:continiu
Set fso = 
CreateObject("Scripting.FileSystemObject
")'
strPath= 
Server.MapPath(".\category\") & 
"\"
Set FSO = 
Server.CreateObject("Scripting.FileSyste
mObject")
FSO.OpenTextFile(strPath & 
sFileName, nForWriting, True).Write 
sNewData
Set FSO = Nothing
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/28/2001 2:08:06 AM:The great sam
Works well on my personal servers, but 
not on my shared one. Any ideas?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
10/23/2001 8:21:28 PM:chrisoleary@att.net
Hi, I was trying to run the upload app 
and got the following error:
Server 
object error 'ASP 0177 : 
800a0046' 
Server.CreateObject Failed 
/UploadWSC/ToFileSystem.asp, line 37 
The operation completed 
successfully.
What am I missing?  
Thanks, Chris.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/12/2001 8:41:26 AM:Dazza
Hi, I was trying to run the upload app 
and got the following 
error:
Server 
object error 'ASP 
0177 : 
800a0046' 
Server.CreateObject Failed 
/UploadWSC/ToFileSystem.asp, line 
37 
The operation completed 
successfully.
Any ideas ?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/13/2001 5:17:07 PM:Shane Poppleton
I am getting the same problem as JF, 
Expected statement 
/upload/clsUpload.asp, line 11 
End Class
    ^
You mentioned 
about not having an if statement 
closed, i have tested you script on 
Win2000, and it worked out of the box, 
but the server hosting our site is NT4, 
and i get the same problem, Does older 
versions of IIS, not support 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/13/2001 5:18:44 PM:Shane Poppleton
"class", sorry message got chopped.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/27/2001 10:02:05 AM:Ahilan
Simply Super. This what i was asking my 
friends for a long time. My Heart Full 
of thanks for your Solution. I faced 
security problem with Filewriting but i 
selected DataBase system. No Problem.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/23/2002 1:02:55 PM:Peter
Trying to add form fields, example, 
text and checkboxes, how do I call the 
value on todatabase.asp?
Thank you, 
great code, worked out of the box!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
1/23/2002 1:03:20 PM:Peter
Trying to add form fields, example, 
text and checkboxes, how do I call the 
value on todatabase.asp?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/23/2002 4:38:09 PM:Jose Rodriguez
As I can show the image kept in mdb 
within a pagina htm?  It does not show 
the image to me.  Response.BinaryWrite 
does not show the image,
interprets it 
like flat text
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/3/2002 9:00:36 PM:Matt Pfingsten
Alright, forgive me if I sound like a 
newbie, but I can't seem to find 
Server.ScriptTimeout in 
ToFileSystem.asp, ToDatabase.asp, or 
clsUpload.asp.
I too would also like 
to know how to add form fields to the 
database along with the file.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/4/2002 1:08:54 PM:Matt Pfingsten
well I figured out the server.timeout 
thing.
But still, how do you add the 
contents of HTML form elements to the 
database?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/22/2002 1:31:54 AM:Carsten Hering
Hi,
I'm having the same problem as 
Shane Poppleton (compilation error in 
clsUpload.asp) when runnig the script 
on the webserver. Did someone find a 
reason or solution to this?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/22/2002 2:09:52 AM:Carsten Hering
Hi again,
I figured it out:
It is 
because of the Version of VBScript.
On 
IIS 4 it's 3.0 and on IIS 5(W2K) it's 
5.0 and the Class Object is only 
supported in 5.0.
Here you can find a 
refernce to all VBScript Versions and 
the awaylable 
Features:
http://msdn.microsoft.com/lib
rary/default.asp?url=/library/en-us/scri
pt56/html/vtoriversioninformation.asp
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/27/2002 1:39:45 PM:Lewis Moten
NEW VERSION OF CODE NOW 
AVAILABLE
http://www.pscode.com/vb/sc
ripts/ShowCode.asp?txtCodeId=7361&lngWId
=4
ENJOY
#########################
###
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
4/29/2002 8:55:13 PM:Dexter Zafra
Can anybody here help me with this 
problem?Am I pointing it to the right 
path? Pls help..Thnx for this nice 
piece og code..
Microsoft VBScript 
compilation (0x800A0411)
Name 
redefined
/dexter/upload/ToFileSystem.a
sp, line 11, column 4
Dim sPath
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/4/2002 4:38:40 AM:Alessandro
the browser gives me this 
error:
Microsoft VBScript 
compilation error '800a03ea' 
Syntax 
error 
/app/clsUpload.asp, line 2 
Class clsUpload
the thing I 
don't understand is that the code works 
perfectly in I create in IIS a virtual 
directory.
It gives that error if I 
run in in a 
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/4/2002 8:59:18 AM:Lewis Moten
Alessandro.  It sounds like you dont 
have the latest vbScript installed.  I 
believe you need at least version 5.0.  
goto 
http://www.microsoft.com/scripting/ 
also, there is a new version of 
this
script on 
PSC.
http://www.pscode.com/vb/scripts
/ShowCode.asp?txtCodeId=7361&lngWId;=4
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/12/2002 4:21:46 AM:Jens Jakobsen
What's this?
Microsoft VBScript 
compilation error '800a0400' 
Expected statement 
/salg/upload/clsUpload.asp, line 11 
End Class
^
I've spent some 
time with it and I am getting grey 
hairs... I have configured the folders 
where the database is AND the folder 
where it says "Uploads" - but every 
time I try to upload I get the before 
mentioned error msg :((((
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/12/2002 4:24:48 AM:Jens Jakobsen
Eh - when I said "configured" I meant 
that the anonymous internet account has 
been given write access.
Is it 
because I have an old IIS 4.0 (and 
IE4.0) server that hasn't  been touched 
(more or less) since it was installed?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/12/2002 11:07:59 AM:Lewis Moten
It appears that the code does not have 
a closing END IF statment somewhere. 
There is now a version 2 for this code.
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.