write binary data (jpg/gif) to disk

Results 1 to 6 of 6

Thread: write binary data (jpg/gif) to disk

  1. #1
    Hunter Guest

    Default write binary data (jpg/gif) to disk

    I&#039m extracting binary data (an image file) from XML and I need to save it to disk. FileSystemObject only handles text files. How do I store the binary data to disk as an image file?

  2. #2
    watcher Guest

    Default RE: write binary data (jpg/gif) to disk

    The FSO will handle binary data fine.

  3. #3
    watcher Guest

    Default RE: write binary data (jpg/gif) to disk

    The FSO will handle binary data fine.

  4. #4
    Hunter Guest

    Default RE: write binary data (jpg/gif) to disk

    I don&#039t mean to argue but this is a quote from a Microsoft resource page "Web developers often need to read binary files from the Web server&#039s file system through Active Server Pages (ASP) and then send the content to the Web browser (for example, to write an Excel file to the browser). Although developers often attempt this with the File System Object (FSO), the FSO is designed to read only ASCII data from the file system and, therefore, does not work."<BR><BR>If you have a code snipet or can point me to a resource to use the FSO to do this or any alternative to the FSO I would greatly appreciate it.<BR><BR>Thanks in advance,<BR><BR>Hunter<BR>

  5. #5
    Join Date
    Dec 1969

    Default more info

    The docs are pretty much correct, in that the first versions of the FSO were not really designed for binary data. They still really are not, but watcher is correct in stating that the FSO can do it anyway. Here&#039s an example of ASP reading binary data with the FSO:<BR> <BR>&nbsp;&nbsp;** http://www.4guysfromrolla.com/webtech/050300-1.shtml<BR><BR>You may want, instead, to investigate the new STREAM object:<BR><BR>&nbsp;&nbsp;**http://www.4guysfromrolla.com/webtech/083100-1.shtml<BR><BR>This is probably the more appropriate way to do what you want.

  6. #6
    Hunter Guest

    Default One more question

    Some very good info but I can&#039t seem to get it all together. Not including the page with the file upload, here is a simplified example of what I&#039m trying to do. I get the error (listed at the bottom of this message) on the write. I&#039m guessing that I need to convert the image data extracted from the form the form to a stream but I&#039m not sure. Any help is greatly appreciated!!!<BR><BR>Hunter<BR><BR>&#060;% @Language = VBSCRIPT %&#062;<BR>&#060;%<BR> FormSize = Request.TotalBytes<BR><BR> &#039Read all form contents<BR> FormData = Request.BinaryRead( FormSize )<BR> <BR> &#039Parse out picture information from form input data<BR> bnCRLF = chrB(13) & chrB(10)<BR> Divider = LEFTB(FormData, INSTRB(FormData, bnCRLF) - 1)<BR> DataStart = INSTRB(FormData, bnCRLF & bnCRLF) + 4<BR> DataEnd = INSTRB(DataStart + 1, FormData, divider) - DataStart<BR> <BR> Dim objStream<BR> Set objStream = Server.CreateObject("ADODB.Stream")<BR> <BR> &#039Open a Binary stream<BR> objStream.Type = adTypeBinary<BR> objStream.Open<BR><BR> &#039Write extracted image data to stream<BR> objStream.Write MIDB(picFile, DataStart, DataEnd)<BR> <BR> objStream.SaveToFile("C:TempmyImage.jpg")<BR> objStream.Close <BR>%&#062;<BR><BR>ADODB.Stream (0x800A0BB9)<BR>Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts