Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Upload

ASP 102

File Upload

by  Bullschmidt  Posted    (Edited  )
First let's deal with the timeout issue which can be a problem if a user is uploading a fairly large file (although perhaps you don't want the timeout increased too much because you DON'T want a user uploading a large file).

For pure ASP (i.e. non component) solutions (and I believe this would be true for component solutions too) can increase the timeout for the page:
' Script timeout in seconds for this page.
' (60 x 60 = 1 hour.)
Server.ScriptTimeout = 60 * 60

Also the Anonymous Internet user needs Change permission on the folder that a file is going to be uploaded to and actually Full Access might be better if you are later going to use the FileSystemObject to delete a file.

Here are some resources for letting the user upload a file which is something that was unfortunately not built into ASP:

ASP File Upload Using VBScript by John R. Lewis - 7/10/2000
http://www.aspzone.com/articles/john/aspUpload
Does NOT use a component.
The clsUpload class uses these other classes: clsCollection, clsFile
Seems to allow for the possibility that a post came in whose form did not have enctype="multipart/form-data" although this doesn't seem to be an issue to me.
There is an internal URLDecode() function in case form submitted with no ENCTYPE="multipart/form-data" in the form tag.
Doesn't have a FileSize property although this can be added.
Assumes the filename will stay the same although it is not hard to slightly modify the class to change this.

UltraFastAspUpload by Cakkie (http://home.planetinternet.be/~aerts1) - 1/3/2002
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=7093&lngWId=4
<<
This page will handle file uploads much faster than other ASP pages. Indeed, this is a 100% ASP solution, so no need to register any additional components. The major speed-gain is caused by the conversion from binary to ANSI. Other codes use a loop and the Chr(AscB(MidB(...))), which is awfully slow. Doing that with a 1 MB file would result in doing a For T = 1 To 1000000. When handling a file, the old code took 25 seconds to process the file. My code needed 2 seconds, need to say more?
>>
Does NOT use a component.
Not a class.
No ContentType.
Assumes the filename will stay the same although it is perhaps not hard to slightly modify the code to change this.
Can't access non-file fields from form.
Cakkie's Web site is not in English.

And here are some other resources:

Applications: File Management: Up/Downloading
http://www.aspin.com/home/webapps/fileoper/upload
Lists resources.

Components: File Management: Up/Downloading
http://www.aspin.com/home/components/file/upload
Lists components.

Planet Source Code search on file upload
http://www.planet-source-code.com and search on upload in the ASP/VBScript category

How do I upload files from the client to the server?
http://www.aspfaq.com/show.asp?id=2189
Lists resources.

Best regards,
J. Paul Schmidt
www.Bullschmidt.com - Freelance ASP Web Developer
www.Bullschmidt.com/DevTip.asp - ASP Web Developer Tips
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top