Upload file to SQL database using classic ASP

13,296

Solution 1

Definately, use freeaspupload to upload the file. It's pretty easy to use. Once you get the file uploaded you will need to binary read the file and then write that binary stream to your db. This website seems to have a working example of what you are trying to do. Look at the code and figure out what parts you need.

Solution 2

As it was mentioned before -- storing binary data in database is usually not good idea.

Wouldn't be good enough to store file on disk, where documents table id/PK becomes file name and store just file name/id, original file name and file description in database?

This would solve most of your problems:

  • Store/generate links to documents in easy way.

  • Easy downloads (just link to file on disk).

This also prevent from problems with fast growing database size and writing and maintaining extra code to store, search for and serve documents stored in database.

If you really need just a link to document this is, in my opinion, better solution.

Here is VB6 code from Microsoft support site which saves uploaded file into file on web server.

Currently it does not do what you want (stores uploaded file on disk, not in database), but I hope it won't be hard to amend that.

Good luck!

Solution 3

(Storing binary data in a database is usually a bad idea.)

Classic ASP doesn't have built-in support for file upload, so you need a upload compontent on the server. For most parts, there are samples included with the upload component that shows how to upload directly into a database.

Solution 4

You can't do this natively with classic ASP yourself, but you can buy ASPUpload to do it for you for $200. If you check their web site, it looks like it hasn't been updated in quite a while, but that's because neither has classic ASP, heh.

I used this myself back in 2001-2005 to upload images, documents, and the like with classic ASP. It's easy to use, easy to get started with, and works great. Two thumbs up.

Solution 5

I've used this "Advanced ASP Uploader" from CodeProject before now. That'll help you get the file to the server. Then you just need to store the bytes in the database.

Whether that's a good idea or not I'll leave to others as there's been a bit of debate about that in this recent thread.

Share:
13,296
Admin
Author by

Admin

Updated on June 26, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to upload files (.doc/.pdf) to a SQL database (2005) but I am really struggling to find any step by step guides.

    This is what happens on my ASP form:

    • User selects a document
    • Document is currently upload to a temp file and sent to a email address

    However it also needs to be stored within a database field.

    I have set the field type within the database to Image. But I am unsure about how I save the binary data information when all I really have is a link to the document (for example C://) from the user.

    I also want to be able to download this document at a later date, this is also possible?

    Thank you in advance for any help.

    Thanks Clare