HELP!!! URGENT!!! how to make the response being a download to the client 
Author Message
 HELP!!! URGENT!!! how to make the response being a download to the client

I have a form (on the client) that as a button...
...and when the client clicks that button, i want to call a webservice which
in response...
....i don't know how....but send's something in the response that makes the
client automatically download a file which is on the server side.
...like this....he(client) clicks the button.....calls a webservice.... the
webservice gives him XXX.zip

HELP PLEASE!!!

Thank you

--
--------------------------------------------------------
Rui Maia
*********************************

*********************************
WEB: http://www.*-*-*.com/ ~rfpm
-----------------------------------------------------



Thu, 30 Dec 2004 00:41:21 GMT  
 HELP!!! URGENT!!! how to make the response being a download to the client


Quote:
> I have a form (on the client) that as a button...
> ...and when the client clicks that button, i want to call a webservice
> which in response...
> ....i don't know how....but send's something in the response that makes
> the client automatically download a file which is on the server side.
> ...like this....he(client) clicks the button.....calls a webservice....
> the webservice gives him XXX.zip

This is a codesnippet I use in normal .ASP. The trick is, you have to
set the mimetype of the returned data. Normally this is html/text related
but if you want to make the browser download the data, you should set it
to unknown. Check the code below.

<%
    ' now, read the file passed at the URL and stream it back to the
    ' client.
    sFilename = request.QueryString("Filename").item
    sTotalPathFilename = server.MapPath("/") & sFilename
    ' strip filename from path
    iPosStartFilename=InstrRev(sFilename,"/")
    if iPosStartFilename = 0 then
        iLenToCopy = len(sFilename)
    else
        iLenToCopy = len(sFilename) - iPosStartFilename
    end if
    sFilename = right(sFilename, iLenToCopy)

    ' Load the file using an ADODB stream object
    'open ADODB Stream
    set cStream = Server.CreateObject("ADODB.Stream")
    cStream.Open
    cStream.Type = 1            'binary
    cStream.LoadFromFile sTotalPathFilename

    ' set mimetype in header
    Response.Clear
    Response.AddHeader "Content-Type", "application/unknown"
    Response.AddHeader "Content-Disposition", "attachment; filename=" & _
                sFilename
    Response.AddHeader "Content-Transfer-Encoding", "Binary"
    Response.BinaryWrite(cStream.Read)

    cStream.Close
    set cStream = nothing
%>

        FB

--
=======  You can't sell what's free  ====================================

Get my free, open source .NET software at   :  http://www.sd.nl/software
=========================================================================



Thu, 30 Dec 2004 18:05:37 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Selecting a Client Certificate-Guys Urgent Help

2. C++ MFC Client : Problem parsing XML response in SPROXY generated class

3. client with thread waiting for response by server through socket

4. Urgent! -- problem downloading app

5. where can download internet client sdk?

6. IaLib - A HTTP and FTP C++ client library available for download

7. IaLib - A HTTP and FTP C++ client library available for download

8. making my own irc client

9. Making a client area for text editor

10. URGENT - Making the mouse move automatically

11. URGENT URGENT dlopen() help needed...

12. URGENT URGENT PLEASE HELP ME ActiveX multiples classes

 

 
Powered by phpBB® Forum Software