Welcome to WebmasterWorld Guest from 54.163.68.15

Forum Moderators: ocean10000

Message Too Old, No Replies

Creating Binary Files

and writing them to disk

   
4:38 pm on Apr 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I have some binary 'content' (i.e. from an image taken out of a database blob) I can easily stream this down to a client using the
Response.BinaryWrite
method.

However, does anybody know how to write the binary file to disk on the web server using ASP (classic) & VBScript?

Had a look round and I can only see how to write text files and load binary files.

Thx in advance

Josh

1:51 pm on Apr 18, 2003 (gmt 0)

10+ Year Member



Classic ASP, You can use the FILEPUT function: [msdn.microsoft.com ] (there's a perfect example at the bottom)

.NET you can use the System.IO.BinaryWriter class
[samples.gotdotnet.com ]

12:28 pm on Apr 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think the pure asp upload class [asp101.com] does this.
8:00 am on Apr 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As far as I can see FilePut is a pure Visual Basic feature and is unavailable to VBScript (and therefore Classic ASP) - I've tried the examples without any success.
12:26 pm on Apr 22, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you check out the class? It looks pretty straightfoward , it writes the binary content to disk using a loop:

Set oFile = oFS.CreateTextFile(sPath & FileName, True)
For nIndex = 1 to LenB(FileData)
oFile.Write Chr(AscB(MidB(FileData,nIndex,1)))
Next