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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Upload Image to DB, then Write Image Data to File

Status
Not open for further replies.

MagnusFox

IS-IT--Management
Jan 12, 2001
51
0
0
US
Good day,

I need to upload an image to a DB, then save that data as a file. The first part is not too hard. I found a nice Class (Loader.asp) that does this for me:

With the image data stored in the DB, I want to write that data to a new file.

I need help understanding how to write the Binary data to the file system.

Again here is the process:
Image upload to DB (done)
Create/save a file of the image data in DB

The craetion of the image file needs to receive its data from the DB and not from the Form upload portion (the image may be created from the DB from time to time after it is stored).

Please, any help on understanding how to save stored data to a file would be great!

===========================
What I tried that failed:

Set rsFile=db.Execute("SELECT Data FROM File WHERE FileID=6")
objFileData = rsFile("Data")

conPathOnServer="D:\Images"
objFileName="test.jpg"

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set objStaticFile = FSO.CreateTextFile(conPathOnServer & objFileName, true)

objStaticFile.Write objFileData
objStaticFile.Close
Set objStaticFile = Nothing
Set FSO = Nothing

This resulted in:
Invalid procedure call or argument

=========================================
Thanks all for your help.
 
1. Do you absolutely have to store your images directly in DB?
2. What is the purpose of writing image data to a new file?
Can't you just upload it?
 
Thanks for the queries:

Yes, I do need to store the images in the DB. The DB is the repository for all site content. Later the production site will be ripped from the DB to create the static public site, both images and HTML pages. So, I do need a way to both place files into and retrieve from the DB and write to the FS.

The reason for not just ULing the image to the FS is that the image may need to written to multiple locations on the FS at a later time. I only want to store the image data in the DB once, then from time to time write an image file to the FS with the data from the DB.

So the issue remains open:
With the image data in the DB, how do I get it out and write it back the FS.

Many thanks,
Mag
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top