Home All Groups Group Topic Archive Search About

Downloading file from database

Author
24 Nov 2005 9:24 PM
Jeremy Chapman
I have build a web page that lists files in a database.  When the user
clicks on the file the page streams the file contents to the browser with
code like:
Response.AppendHeader("Content-Disposition","attachment;filename=" +
strFileName);
Response.AppendHeader("Content-Length",lLength.ToString());
Response.ContentType = strContentType;
Response.BinaryWrite(binData);

My problem is that if the file is html or xml, it appears in the browser
window.  If the file is jpg, text, etc it appears in a seperate application
window.  The desired behaviour is to always show the document in a seperate
window, but I can't write specific code to handle each file type
individually.   Is it possible to force the file to download a view in a
seperate window?

Author
24 Nov 2005 9:31 PM
Edwin Knoppert
Just the correct content type.
I enforce downloading PDF instead of viewing it this way.


Show quoteHide quote
"Jeremy Chapman" <m*@here.com> schreef in bericht
news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl...
>I have build a web page that lists files in a database.  When the user
>clicks on the file the page streams the file contents to the browser with
>code like:
> Response.AppendHeader("Content-Disposition","attachment;filename=" +
> strFileName);
> Response.AppendHeader("Content-Length",lLength.ToString());
> Response.ContentType = strContentType;
> Response.BinaryWrite(binData);
>
> My problem is that if the file is html or xml, it appears in the browser
> window.  If the file is jpg, text, etc it appears in a seperate
> application window.  The desired behaviour is to always show the document
> in a seperate window, but I can't write specific code to handle each file
> type individually.   Is it possible to force the file to download a view
> in a seperate window?
>
Are all your drivers up to date? click for free checkup

Author
24 Nov 2005 10:12 PM
Jeremy Chapman
The type is correct.  But for some types windows displays them using IE, and
in that case it displays it in the same window as the list of files.  If
it's in IE, I want it to display in a seperate window.


Show quoteHide quote
"Edwin Knoppert" <i***@pbsoft.speedlinq.nl> wrote in message
news:dm5bfs$ok1$1@azure.qinip.net...
> Just the correct content type.
> I enforce downloading PDF instead of viewing it this way.
>
>
> "Jeremy Chapman" <m*@here.com> schreef in bericht
> news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl...
>>I have build a web page that lists files in a database.  When the user
>>clicks on the file the page streams the file contents to the browser with
>>code like:
>> Response.AppendHeader("Content-Disposition","attachment;filename=" +
>> strFileName);
>> Response.AppendHeader("Content-Length",lLength.ToString());
>> Response.ContentType = strContentType;
>> Response.BinaryWrite(binData);
>>
>> My problem is that if the file is html or xml, it appears in the browser
>> window.  If the file is jpg, text, etc it appears in a seperate
>> application window.  The desired behaviour is to always show the document
>> in a seperate window, but I can't write specific code to handle each file
>> type individually.   Is it possible to force the file to download a view
>> in a seperate window?
>>
>
>
Author
24 Nov 2005 10:33 PM
Edwin Knoppert
Oh, i meant it the other way around, by NOT using the real type like pdf but
that inary, you get the download fialog.
But now i see you don't want that.
You might consider to open an new window and point to the pdf.
But i don't think you'll be able to determine if the pdf get's loaded IN the
window or not.

So, leave it to the user..



Show quoteHide quote
"Jeremy Chapman" <m*@here.com> schreef in bericht
news:%23oL8xQU8FHA.2816@tk2msftngp13.phx.gbl...
> The type is correct.  But for some types windows displays them using IE,
> and in that case it displays it in the same window as the list of files.
> If it's in IE, I want it to display in a seperate window.
>
>
> "Edwin Knoppert" <i***@pbsoft.speedlinq.nl> wrote in message
> news:dm5bfs$ok1$1@azure.qinip.net...
>> Just the correct content type.
>> I enforce downloading PDF instead of viewing it this way.
>>
>>
>> "Jeremy Chapman" <m*@here.com> schreef in bericht
>> news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl...
>>>I have build a web page that lists files in a database.  When the user
>>>clicks on the file the page streams the file contents to the browser with
>>>code like:
>>> Response.AppendHeader("Content-Disposition","attachment;filename=" +
>>> strFileName);
>>> Response.AppendHeader("Content-Length",lLength.ToString());
>>> Response.ContentType = strContentType;
>>> Response.BinaryWrite(binData);
>>>
>>> My problem is that if the file is html or xml, it appears in the browser
>>> window.  If the file is jpg, text, etc it appears in a seperate
>>> application window.  The desired behaviour is to always show the
>>> document in a seperate window, but I can't write specific code to handle
>>> each file type individually.   Is it possible to force the file to
>>> download a view in a seperate window?
>>>
>>
>>
>
>
Author
25 Nov 2005 1:58 AM
Casper Stendal
Hi Jeremy

You just have to put your page stream code in a seperate file, and then link
to that file with window.open() or target="_blank", when everything should
work just like you want... ;)

/Stendal

Show quoteHide quote
"Jeremy Chapman" <m*@here.com> skrev i en meddelelse
news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl...
>I have build a web page that lists files in a database.  When the user
>clicks on the file the page streams the file contents to the browser with
>code like:
> Response.AppendHeader("Content-Disposition","attachment;filename=" +
> strFileName);
> Response.AppendHeader("Content-Length",lLength.ToString());
> Response.ContentType = strContentType;
> Response.BinaryWrite(binData);
>
> My problem is that if the file is html or xml, it appears in the browser
> window.  If the file is jpg, text, etc it appears in a seperate
> application window.  The desired behaviour is to always show the document
> in a seperate window, but I can't write specific code to handle each file
> type individually.   Is it possible to force the file to download a view
> in a seperate window?
>

Bookmark and Share