Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[2235] Send Binary Data from ASP

Last post 02-12-2006 2:21 AM by ckchan. 45 replies.
Page 1 of 4 (46 items) 1 2 3 4 Next >
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [2235] Send Binary Data from ASP

    This thread is for discussions of Send Binary Data from ASP.

    • Post Points: 0
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 05-05-2002 1:10 AM In reply to

    Macintosh IE 5.1 compatibility

    Hi,

    I tried your tutorial.  Works great on Windows and IE 5.5+.  But my Mac running IE 5.1 doesn't work.  The Save As dialog did not show up on Mac.

    Please help.
    • Post Points: 0
  • 05-08-2002 2:25 PM In reply to

    I don't have immediate access to a Mac to try this out.  Let me do some digging and get back to you.
    • Post Points: 0
  • 05-26-2002 2:43 AM In reply to

    So I've been cogitating on this for awhile.  There is nothing sophisticated in the HTML code (at least, not from a standards perspective), so the answer has to lie elsewhere.  Had me stumped.  But as I was showering this morning, it struck me.  Maybe it has something to do with the content type values.  I don't know what they are supposed to be for the Macintosh.  You might want to try setting it to 'application/octet-stream'.  That is sort of the default type for use in Mac's (I believe).

    Hope this helps.
    • Post Points: 0
  • 05-26-2002 9:28 AM In reply to

    Octet-stream tried

    Yes, I did use "octet-stream" as the content type.  But the Mac IE 5.1 still does not recognize it as a "File->Save As" action.  Is there a way at all to make this work with the Mac?  It seems very happy on Windows.

    Quote:
    [1]Posted by LACanadian on 26 May 2002 02:43 AM[/1]
    So I've been cogitating on this for awhile.  There is nothing sophisticated in the HTML code (at least, not from a standards perspective), so the answer has to lie elsewhere.  Had me stumped.  But as I was showering this morning, it struck me.  Maybe it has something to do with the content type values.  I don't know what they are supposed to be for the Macintosh.  You might want to try setting it to 'application/octet-stream'.  That is sort of the default type for use in Mac's (I believe).

    Hope this helps.

    • Post Points: 0
  • 05-27-2002 2:25 PM In reply to

    Have you tried adding another header of the form 'Content-Disposition: filename="fname"' to the request?
    • Post Points: 0
  • 09-30-2002 3:21 PM In reply to

    • tyniuz
    • Not Ranked
    • Joined on 09-30-2002
    • New Member
    • Points 10

    Simple the best !

    Use this code and you do not need any special components or any other techniques.


    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.OpenTextFile("c:\inetpub\file.gif", 1, 0)
    Do While a.AtEndOfStream <>True
      retstring = a.Read(1)
      response.binarywrite(chrb(asc(retstring)))
    loop
    a.close


    Off course this will slow your server because it must convert (in example) 10 000 of bytes, but i do not think that you will feel it (also with big files).
    • Post Points: 0
  • 12-10-2002 3:11 PM In reply to

    Can't open PDF file

    I followed the example, but when the dialog box pops up in the browser it shows that it wants to download the file that is an ASP page it-self that contains this code, I can't get it to download PDF file.

    Please help!

    Nevermind, I found it.
    Thanks.
    • Post Points: 0
  • 12-16-2002 6:31 PM In reply to

    • acuze104
    • Not Ranked
    • Joined on 12-16-2002
    • New Member
    • Points 10

    can't open pdf file 2

    I'm having the same exact problem.. " dialog box pops up in the browser it shows that it wants to download the file that is an ASP page it-self that contains this code, I can't get it to download PDF file. "   I need help with this ASAP...  


    I"m using a third party software called "activepdf toolkit" to create the pdf and put it in memory.  After it is done creating, i use this code  to display the pdf to the browser.


    response.ContentType = "application/pdf"
    response.AddHeader "Content-Type", "application/pdf"
    response.addHeader "Content-Disposition", "filename=part"&hour(Now)&""&minute(Now)&".PDF"

    This works fine in IE 5.0 and above for windows.. but not on the mac version.  


    Thanks in advance..
    • Post Points: 0
  • 12-19-2002 1:41 PM In reply to

    here is my code that works, it in JavaScript (shouldn't make any difference):

                                   <%@  Language=JavaScript %>  
                                   <%
                                   // some code to get binary pdf.

           Response.Clear();
           Response.Buffer = true;
           Response.AddHeader("Content-Disposition", "attachment; filename=" + tFileName);
           Response.ContentType = "application/pdf";
           Response.BinaryWrite(tPDF);
                                   %>

    Make sure before these lines you don't write anything into response and remove all html code from this page, try this by only leaving server side code, this is how I got mine working.

    good luck.
    • Post Points: 0
  • 01-02-2003 12:34 PM In reply to

    • acuze104
    • Not Ranked
    • Joined on 12-16-2002
    • New Member
    • Points 10
    I was wondering. Is there any settings I need to do on the mac to enable the opening of a pdf. I am running MAC OS X  , IE 5.2.  I was reading online for all the settings for the mac browser to open up a pdf but it doesn't work. Any help is appreciated.  Thanks
    • Post Points: 0
  • 01-04-2003 1:17 AM In reply to

    • thaiirc
    • Not Ranked
    • Joined on 01-04-2003
    • New Member
    • Points 5
    ?????????? ?? ?? ??????? http://www.thaiirc.com
    • Post Points: 0
  • 01-13-2003 8:51 PM In reply to

    PDF file doesn't open in browser window, it pops u

    here is my code:

    Dim tFileName
    tFileName = "web_report.pdf"
    Response.Clear
    Response.Buffer = True
    Response.AddHeader "Content-Disposition", "attachment; filename=" & tFileName
    Response.ContentType = "application/pdf"
    Response.BinaryWrite tPDF


    it doesn't open a PDF file in my browser window?
    can you please help!?
    I need it ASAP.

    Thank you!
    • Post Points: 0
  • 01-17-2003 7:26 AM In reply to

    • scottuk
    • Not Ranked
    • Joined on 01-17-2003
    • New Member
    • Points 50

    Needed Two Articles to Get the result I needed.

    Thanks for the code , maybe im being a little thick , but there is no mention of the
    oUtilityObject referenced within this example code.

    I managed to work it out using this article and another from here ..

    http://www.developerfusion.com/show/2542

    My working version of these two pieces of code is as follows ...

    Code:
    <%

    Function getBinaryFile(strFilePath)

     Dim TypeBinary, oStream
     
     
     TypeBinary = 1   ' Indicates a binary file
     
     ' Create the object
     Set oStream = Server.CreateObject("ADODB.Stream")
     
     ' Open our file
     oStream.Open
     
     ' Retreive binary data from the file
     oStream.Type = TypeBinary
     oStream.LoadFromFile strFilePath
     
     
     ' Return the binary data to the caller
     getBinaryFile = oStream.read
     
     ' Destroy the ADO object  
     Set oStream = Nothing

    End Function
    sServerFile = Server.MapPath("/therealfilelocation/private/CTC012.pdf")
    'sFile = "CTC012.pdf"
    Response.Buffer = True
    Response.Clear
    ' I want the file displayed within the browser so dont specify a filename
    'Response.AddHeader "content-disposition", "attachment; filename=" & sFile
    Response.ContentType = "application/pdf"  
    Response.BinaryWrite getBinaryFile(Server.MapPath("/therealfilelocation/private/CTC012.pdf"))
    Response.end
    %>


    It is worth noting that when I specified a filename if the user chose the "open file" option instead of the "save file" option when prompted by Internet Explorer Acrobat reader displays the error "File Not Found" after IE has downloaded the data.

    To get around this and to make the page look nicer , i commented out the filename part.

    This means Internet Explorer Opens it via Acrobat in the browser (if configured).

    I have not tested MACS or other Browsers yet.

    Hope this helps someone.
    • Post Points: 0
  • 01-17-2003 8:33 AM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 15,055
    • SystemAdministrator
    To clarify, oUtilityObject simply contains the code on http://www.developerfusion.com/show/2235/2/, which is compiled into a VB DLL, and then called from the ASP code on the next page.
    • Post Points: 0
Page 1 of 4 (46 items) 1 2 3 4 Next >