Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Save as Dialog Box


Message #1 by "Adeola" <aoadeyemo@h...> on Tue, 4 Dec 2001 13:49:04
Hi all,

i don't mean to bore u guys and ladies but is it possible to bring up a 

save as dialog box using VBScript in ASP ? eg having a button to open up 

the box for users to either choose afiule or enter a new file name.

Any ideas?

Thanx

Ade'
Message #2 by "Daniel O'Dorisio" <daniel@o...> on Tue, 4 Dec 2001 08:54:29 -0500
yeah.. put a link to the file.. if the browser isnt configured to open it

automatically (.pdf, .mp3, .doc, .ppt, or something else) they will get the

save as dialog.



daniel



--

-----------------------------

Daniel O'Dorisio

daniel@o...

www.odorisio-networks.com

-----------------------------

"Adeola" <aoadeyemo@h...> wrote in message

news:125790@a..._web_howto...

:

: Hi all,

: i don't mean to bore u guys and ladies but is it possible to bring up a

: save as dialog box using VBScript in ASP ? eg having a button to open up

: the box for users to either choose afiule or enter a new file name.

: Any ideas?

: Thanx

: Ade'

:

:





Message #3 by "Adeola" <aoadeyemo@h...> on Tue, 4 Dec 2001 17:12:23
Hi Daniel,

Thanx for replying. I don't quite understand the scenario. hoe do i check 

if the browser is configured to open it or not and a link to which file, 

will that be the one the user is about to save to?

Much appreciated

Ade'  





> yeah.. put a link to the file.. if the browser isnt configured to open it

> automatically (.pdf, .mp3, .doc, .ppt, or something else) they will get 

the

> save as dialog.

> 

> daniel

> 

> --

> -----------------------------

> Daniel O'Dorisio

> daniel@o...

> www.odorisio-networks.com

> -----------------------------

> "Adeola" <aoadeyemo@h...> wrote in message

> news:125790@a..._web_howto...

> :

> : Hi all,

> : i don't mean to bore u guys and ladies but is it possible to bring up a

> : save as dialog box using VBScript in ASP ? eg having a button to open 

up

> : the box for users to either choose afiule or enter a new file name.

> : Any ideas?

> : Thanx

> : Ade'

> :

> :

> 

> 

Message #4 by "Daniel O'Dorisio" <daniel@o...> on Tue, 4 Dec 2001 13:50:03 -0500
its like this..



when the server sends back content that is other then html it looks for a

way to open it.. if it is configured correct. it will open that file. else

it will ask the user to download it... just put a link in your page to the

file, watch what happens.. if it is a .doc file, and you have word, and are

using ie.. the doc should open in an embedded version of word.



does this help?



daniel



--

-----------------------------

Daniel O'Dorisio

daniel@o...

www.odorisio-networks.com

-----------------------------

"Adeola" <aoadeyemo@h...> wrote in message

news:125886@a..._web_howto...

:

: Hi Daniel,

: Thanx for replying. I don't quite understand the scenario. hoe do i check

: if the browser is configured to open it or not and a link to which file,

: will that be the one the user is about to save to?

: Much appreciated

: Ade'

:

:

: > yeah.. put a link to the file.. if the browser isnt configured to open

it

: > automatically (.pdf, .mp3, .doc, .ppt, or something else) they will get

: the

: > save as dialog.

: >

: > daniel

: >

: > --

: > -----------------------------

: > Daniel O'Dorisio

: > daniel@o...

: > www.odorisio-networks.com

: > -----------------------------

: > "Adeola" <aoadeyemo@h...> wrote in message

: > news:125790@a..._web_howto...

: > :

: > : Hi all,

: > : i don't mean to bore u guys and ladies but is it possible to bring up

a

: > : save as dialog box using VBScript in ASP ? eg having a button to open

: up

: > : the box for users to either choose afiule or enter a new file name.

: > : Any ideas?

: > : Thanx

: > : Ade'

: > :

: > :

: >

: >

:

:





Message #5 by Imar Spaanjaars <Imar@S...> on Tue, 04 Dec 2001 20:06:08 +0100
Even with registered file types, like HTML and .DOC files, it IS possible 

to force both the download dialog and a filename.



Try something like this (watch for wrapping):



Response.Buffer = True

sFullFileName = "C:\Attachments\File1.doc" ' file on your server

sFileName = "File1.doc" ' filename the user will see

Response.Contenttype="application/x-unknown"

Response.Addheader "Content-Disposition", "attachment; filename=" & chr(34) 

& sFileName & chr(34)

Response.Binarywrite GetBinaryFile(sFullFileName)



Function GetBinaryFile(ByVal sFileSpec)

      Const adTypeBinary = 1

      Dim objStream

      Set objStream = Server.Createobject("ADODB.Stream")

      objStream.Open

      objStream.Type = adTypeBinary

      objStream.LoadFromFile sFileSpec

      GetBinaryFile = objStream.read

      Set objStream = Nothing

End Function





This will use the ADODB Stream object to push contents of the file to the

browser. Since the content type is set to "application/x-unknown", the

browser will pop up a Save As dialog instead of opening the file in the

browser / plugin. The name defined by sFileName will be the name that is 

displayed in the Save As dialog







Hope this helps,



Imar





At 01:50 PM 12/4/2001 -0500, you wrote:

>its like this..

>

>when the server sends back content that is other then html it looks for a

>way to open it.. if it is configured correct. it will open that file. else

>it will ask the user to download it... just put a link in your page to the

>file, watch what happens.. if it is a .doc file, and you have word, and are

>using ie.. the doc should open in an embedded version of word.

>

>does this help?

>

>daniel

>

>--

>-----------------------------

>Daniel O'Dorisio

>daniel@o...

>www.odorisio-networks.com

>-----------------------------

>"Adeola" <aoadeyemo@h...> wrote in message

>news:125886@a..._web_howto...

>:

>: Hi Daniel,

>: Thanx for replying. I don't quite understand the scenario. hoe do i check

>: if the browser is configured to open it or not and a link to which file,

>: will that be the one the user is about to save to?

>: Much appreciated

>: Ade'

>:

>:

>: > yeah.. put a link to the file.. if the browser isnt configured to open

>it

>: > automatically (.pdf, .mp3, .doc, .ppt, or something else) they will get

>: the

>: > save as dialog.

>: >

>: > daniel

>: >

>: > --

>: > -----------------------------

>: > Daniel O'Dorisio

>: > daniel@o...

>: > www.odorisio-networks.com

>: > -----------------------------

>: > "Adeola" <aoadeyemo@h...> wrote in message

>: > news:125790@a..._web_howto...

>: > :

>: > : Hi all,

>: > : i don't mean to bore u guys and ladies but is it possible to bring up

>a

>: > : save as dialog box using VBScript in ASP ? eg having a button to open

>: up

>: > : the box for users to either choose afiule or enter a new file name.

>: > : Any ideas?

>: > : Thanx

>: > : Ade'

>: > :

>: > :

>: >

>: >

>:

>:

>

>

>








Message #6 by "Dilg, Jared (US - Hermitage)" <jdilg@d...> on Tue, 4 Dec 2001 13:10:36 -0600
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C17CF7.5AC29288

Content-Type: text/plain



Daniel, I think what Adeola and myself included would like to know is,

whether or not you can force the browser to create a save dialog box rather

than leave the browser to decide if it can embed the associated application

such as MSWord or Acrobat Reader. I thought I read somewhere there was a way

to do this, not sure.



-Jared Dilg



-----Original Message-----

From: Daniel O'Dorisio [mailto:daniel@o...] 

Sent: Tuesday, December 04, 2001 12:50 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: Save as Dialog Box





its like this..



when the server sends back content that is other then html it looks for a

way to open it.. if it is configured correct. it will open that file. else

it will ask the user to download it... just put a link in your page to the

file, watch what happens.. if it is a .doc file, and you have word, and are

using ie.. the doc should open in an embedded version of word.



does this help?



daniel



--

-----------------------------

Daniel O'Dorisio

daniel@o...

www.odorisio-networks.com

-----------------------------

"Adeola" <aoadeyemo@h...> wrote in message

news:125886@a..._web_howto...

:

: Hi Daniel,

: Thanx for replying. I don't quite understand the scenario. hoe do i check

: if the browser is configured to open it or not and a link to which file,

: will that be the one the user is about to save to?

: Much appreciated

: Ade'

:

:

: > yeah.. put a link to the file.. if the browser isnt configured to open

it

: > automatically (.pdf, .mp3, .doc, .ppt, or something else) they will get

: the

: > save as dialog.

: >

: > daniel

: >

: > --

: > -----------------------------

: > Daniel O'Dorisio

: > daniel@o...

: > www.odorisio-networks.com

: > -----------------------------

: > "Adeola" <aoadeyemo@h...> wrote in message

: > news:125790@a..._web_howto...

: > :

: > : Hi all,

: > : i don't mean to bore u guys and ladies but is it possible to bring up

a

: > : save as dialog box using VBScript in ASP ? eg having a button to open

: up

: > : the box for users to either choose afiule or enter a new file name.

: > : Any ideas?

: > : Thanx

: > : Ade'

: > :

: > :

: >

: >

:

:







---

You are currently subscribed to asp_web_howto as: jdilg@d... To

unsubscribe send a blank email to $subst('Email.Unsub')

- This message (including any attachments) contains confidential information

intended for a specific individual and purpose, and is protected by law.  -

If you are not the intended recipient, you should delete this message and

are hereby notified that any disclosure, copying, or distribution of this

message, or the taking of any action based on it, is strictly prohibited.




Message #7 by "Dilg, Jared (US - Hermitage)" <jdilg@d...> on Tue, 4 Dec 2001 13:12:50 -0600
This message is in MIME format. Since your mail reader does not understand

this format, some or all of this message may not be legible.



------_=_NextPart_001_01C17CF7.AA637DCA

Content-Type: text/plain



That's beautiful! Thanks Imar! My recent post was about 30sec too late! Hehe



-Jared



-----Original Message-----

From: Imar Spaanjaars [mailto:Imar@S...] 

Sent: Tuesday, December 04, 2001 1:06 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Re: Save as Dialog Box





Even with registered file types, like HTML and .DOC files, it IS possible 

to force both the download dialog and a filename.



Try something like this (watch for wrapping):



Response.Buffer = True

sFullFileName = "C:\Attachments\File1.doc" ' file on your server sFileName 

"File1.doc" ' filename the user will see

Response.Contenttype="application/x-unknown"

Response.Addheader "Content-Disposition", "attachment; filename=" & chr(34) 

& sFileName & chr(34)

Response.Binarywrite GetBinaryFile(sFullFileName)



Function GetBinaryFile(ByVal sFileSpec)

      Const adTypeBinary = 1

      Dim objStream

      Set objStream = Server.Createobject("ADODB.Stream")

      objStream.Open

      objStream.Type = adTypeBinary

      objStream.LoadFromFile sFileSpec

      GetBinaryFile = objStream.read

      Set objStream = Nothing

End Function





This will use the ADODB Stream object to push contents of the file to the

browser. Since the content type is set to "application/x-unknown", the

browser will pop up a Save As dialog instead of opening the file in the

browser / plugin. The name defined by sFileName will be the name that is 

displayed in the Save As dialog







Hope this helps,



Imar





At 01:50 PM 12/4/2001 -0500, you wrote:

>its like this..

>

>when the server sends back content that is other then html it looks for 

>a way to open it.. if it is configured correct. it will open that file. 

>else it will ask the user to download it... just put a link in your 

>page to the file, watch what happens.. if it is a .doc file, and you 

>have word, and are using ie.. the doc should open in an embedded 

>version of word.

>

>does this help?

>

>daniel

>

>--

>-----------------------------

>Daniel O'Dorisio

>daniel@o...

>www.odorisio-networks.com

>-----------------------------

>"Adeola" <aoadeyemo@h...> wrote in message 

>news:125886@a..._web_howto...

>:

>: Hi Daniel,

>: Thanx for replying. I don't quite understand the scenario. hoe do i 

>check

>: if the browser is configured to open it or not and a link to which file,

>: will that be the one the user is about to save to?

>: Much appreciated

>: Ade'

>:

>:

>: > yeah.. put a link to the file.. if the browser isnt configured to open

>it

>: > automatically (.pdf, .mp3, .doc, .ppt, or something else) they will get

>: the

>: > save as dialog.

>: >

>: > daniel

>: >

>: > --

>: > -----------------------------

>: > Daniel O'Dorisio

>: > daniel@o...

>: > www.odorisio-networks.com

>: > -----------------------------

>: > "Adeola" <aoadeyemo@h...> wrote in message

>: > news:125790@a..._web_howto...

>: > :

>: > : Hi all,

>: > : i don't mean to bore u guys and ladies but is it possible to bring up

>a

>: > : save as dialog box using VBScript in ASP ? eg having a button to open

>: up

>: > : the box for users to either choose afiule or enter a new file name.

>: > : Any ideas?

>: > : Thanx

>: > : Ade'

>: > :

>: > :

>: >

>: >

>:

>:

>

>

>




>$subst('Email.Unsub')







---

You are currently subscribed to asp_web_howto as: jdilg@d... To

unsubscribe send a blank email to $subst('Email.Unsub')

- This message (including any attachments) contains confidential information

intended for a specific individual and purpose, and is protected by law.  -

If you are not the intended recipient, you should delete this message and

are hereby notified that any disclosure, copying, or distribution of this

message, or the taking of any action based on it, is strictly prohibited.




Message #8 by Imar Spaanjaars <Imar@S...> on Tue, 04 Dec 2001 20:14:10 +0100
One small wrapping problem, though:



sFullFileName = "C:\Attachments\File1.doc" ' file on your server sFileName 

= "File1.doc" ' filename the user will see 

Response.Contenttype="application/x-unknown"





should be:



sFullFileName = "C:\Attachments\File1.doc" ' file on your server

sFileName = "File1.doc" ' filename the user will see

Response.Contenttype="application/x-unknown"



and & sFileName & chr(34)  should be placed right after the previous 

chr(34) of the previous line.



HtH



Imar





At 01:12 PM 12/4/2001 -0600, you wrote:



>That's beautiful! Thanks Imar! My recent post was about 30sec too late! Hehe

>

>-Jared

>

>-----Original Message-----

>From: Imar Spaanjaars 

>[<mailto:Imar@S...>mailto:Imar@S...]

>Sent: Tuesday, December 04, 2001 1:06 PM

>To: ASP Web HowTo

>Subject: [asp_web_howto] Re: Save as Dialog Box

>

>Even with registered file types, like HTML and .DOC files, it IS possible

>to force both the download dialog and a filename.

>

>Try something like this (watch for wrapping):

>

>Response.Buffer = True

>sFullFileName = "C:\Attachments\File1.doc" ' file on your server sFileName 

>= "File1.doc" ' filename the user will see 

>Response.Contenttype="application/x-unknown"

>

>Response.Addheader "Content-Disposition", "attachment; filename=" & chr(34)

>& sFileName & chr(34)

>Response.Binarywrite GetBinaryFile(sFullFileName)

>

>Function GetBinaryFile(ByVal sFileSpec)

>       Const adTypeBinary = 1

>       Dim objStream

>       Set objStream = Server.Createobject("ADODB.Stream")

>       objStream.Open

>       objStream.Type = adTypeBinary

>       objStream.LoadFromFile sFileSpec

>       GetBinaryFile = objStream.read

>       Set objStream = Nothing

>End Function

>

>This will use the ADODB Stream object to push contents of the file to the 

>browser. Since the content type is set to "application/x-unknown", the 

>browser will pop up a Save As dialog instead of opening the file in the 

>browser / plugin. The name defined by sFileName will be the name that is

>

>displayed in the Save As dialog

>

>

>Hope this helps,

>

>Imar

>

>At 01:50 PM 12/4/2001 -0500, you wrote:

> >its like this..

> >

> >when the server sends back content that is other then html it looks for

> >a way to open it.. if it is configured correct. it will open that file.

> >else it will ask the user to download it... just put a link in your

> >page to the file, watch what happens.. if it is a .doc file, and you

> >have word, and are using ie.. the doc should open in an embedded

> >version of word.

> >

> >does this help?

> >

> >daniel

> >

> >--

> >-----------------------------

> >Daniel O'Dorisio

> >daniel@o...

> >www.odorisio-networks.com

> >-----------------------------

> >"Adeola" <aoadeyemo@h...> wrote in message

> ><news:125886@a..._web_howto>news:125886@a..._web_howto...

> >:

> >: Hi Daniel,

> >: Thanx for replying. I don't quite understand the scenario. hoe do i

> >check

> >: if the browser is configured to open it or not and a link to which file,

> >: will that be the one the user is about to save to?

> >: Much appreciated

> >: Ade'

> >:

> >:

> >: > yeah.. put a link to the file.. if the browser isnt configured to open

> >it

> >: > automatically (.pdf, .mp3, .doc, .ppt, or something else) they will get

> >: the

> >: > save as dialog.

> >: >

> >: > daniel

> >: >

> >: > --

> >: > -----------------------------

> >: > Daniel O'Dorisio

> >: > daniel@o...

> >: > www.odorisio-networks.com

> >: > -----------------------------

> >: > "Adeola" <aoadeyemo@h...> wrote in message

> >: > <news:125790@a..._web_howto>news:125790@a..._web_howto...

> >: > :

> >: > : Hi all,

> >: > : i don't mean to bore u guys and ladies but is it possible to bring up

> >a

> >: > : save as dialog box using VBScript in ASP ? eg having a button to open

> >: up

> >: > : the box for users to either choose afiule or enter a new file name.

> >: > : Any ideas?

> >: > : Thanx

> >: > : Ade'

> >: > :

> >: > :

> >: >

> >: >

> >:

> >:

> >

> >

> >




> >$subst('Email.Unsub')

>

>

>---

>You are currently subscribed to asp_web_howto as: jdilg@d... To 

>unsubscribe send a blank email to $subst('Email.Unsub')

>

>- This message (including any attachments) contains confidential 

>information intended for a specific individual and purpose, and is 

>protected by law.  - If you are not the intended recipient, you should 

>delete this message and are hereby notified that any disclosure, copying, 

>or distribution of this message, or the taking of any action based on it, 

>is strictly prohibited.








Message #9 by "Daniel O'Dorisio" <daniel@o...> on Tue, 4 Dec 2001 15:24:05 -0500
oh yeah.. that is true... sorry.. i guess i missed the point.. my

apalogies.. thanks imar!



daniel



--

-----------------------------

Daniel O'Dorisio

daniel@o...

www.odorisio-networks.com

-----------------------------

"Imar Spaanjaars" <Imar@S...> wrote in message

news:125928@a..._web_howto...

:

: Even with registered file types, like HTML and .DOC files, it IS possible

: to force both the download dialog and a filename.

:

: Try something like this (watch for wrapping):

:

: Response.Buffer = True

: sFullFileName = "C:\Attachments\File1.doc" ' file on your server

: sFileName = "File1.doc" ' filename the user will see

: Response.Contenttype="application/x-unknown"

: Response.Addheader "Content-Disposition", "attachment; filename=" &

chr(34)

: & sFileName & chr(34)

: Response.Binarywrite GetBinaryFile(sFullFileName)

:

: Function GetBinaryFile(ByVal sFileSpec)

:       Const adTypeBinary = 1

:       Dim objStream

:       Set objStream = Server.Createobject("ADODB.Stream")

:       objStream.Open

:       objStream.Type = adTypeBinary

:       objStream.LoadFromFile sFileSpec

:       GetBinaryFile = objStream.read

:       Set objStream = Nothing

: End Function

:

:

: This will use the ADODB Stream object to push contents of the file to the

: browser. Since the content type is set to "application/x-unknown", the

: browser will pop up a Save As dialog instead of opening the file in the

: browser / plugin. The name defined by sFileName will be the name that is

: displayed in the Save As dialog

:

:

:

: Hope this helps,

:

: Imar

:

:

: At 01:50 PM 12/4/2001 -0500, you wrote:

: >its like this..

: >

: >when the server sends back content that is other then html it looks for a

: >way to open it.. if it is configured correct. it will open that file.

else

: >it will ask the user to download it... just put a link in your page to

the

: >file, watch what happens.. if it is a .doc file, and you have word, and

are

: >using ie.. the doc should open in an embedded version of word.

: >

: >does this help?

: >

: >daniel

: >

: >--

: >-----------------------------

: >Daniel O'Dorisio

: >daniel@o...

: >www.odorisio-networks.com

: >-----------------------------

: >"Adeola" <aoadeyemo@h...> wrote in message

: >news:125886@a..._web_howto...

: >:

: >: Hi Daniel,

: >: Thanx for replying. I don't quite understand the scenario. hoe do i

check

: >: if the browser is configured to open it or not and a link to which

file,

: >: will that be the one the user is about to save to?

: >: Much appreciated

: >: Ade'

: >:

: >:

: >: > yeah.. put a link to the file.. if the browser isnt configured to

open

: >it

: >: > automatically (.pdf, .mp3, .doc, .ppt, or something else) they will

get

: >: the

: >: > save as dialog.

: >: >

: >: > daniel

: >: >

: >: > --

: >: > -----------------------------

: >: > Daniel O'Dorisio

: >: > daniel@o...

: >: > www.odorisio-networks.com

: >: > -----------------------------

: >: > "Adeola" <aoadeyemo@h...> wrote in message

: >: > news:125790@a..._web_howto...

: >: > :

: >: > : Hi all,

: >: > : i don't mean to bore u guys and ladies but is it possible to bring

up

: >a

: >: > : save as dialog box using VBScript in ASP ? eg having a button to

open

: >: up

: >: > : the box for users to either choose afiule or enter a new file name.

: >: > : Any ideas?

: >: > : Thanx

: >: > : Ade'

: >: > :

: >: > :

: >: >

: >: >

: >:

: >:

: >

: >

: >




:

:

:

:





Message #10 by Imar Spaanjaars <Imar@S...> on Tue, 04 Dec 2001 21:46:29 +0100
Yeah, no problem. I don't think his initial question was all that clear ;-) 

Just saw this type of question come along quite a few times, so I figured 

that was what he wanted.



Cheers,



Imar





At 03:24 PM 12/4/2001 -0500, you wrote:

>oh yeah.. that is true... sorry.. i guess i missed the point.. my

>apalogies.. thanks imar!

>

>daniel

>

>--

>-----------------------------

>Daniel O'Dorisio

>daniel@o...

>www.odorisio-networks.com

>-----------------------------

>"Imar Spaanjaars" <Imar@S...> wrote in message

>news:125928@a..._web_howto...

>:

>: Even with registered file types, like HTML and .DOC files, it IS possible

>: to force both the download dialog and a filename.

>:

>: Try something like this (watch for wrapping):

>:

>: Response.Buffer = True

>: sFullFileName = "C:\Attachments\File1.doc" ' file on your server

>: sFileName = "File1.doc" ' filename the user will see

>: Response.Contenttype="application/x-unknown"

>: Response.Addheader "Content-Disposition", "attachment; filename=" &

>chr(34)

>: & sFileName & chr(34)

>: Response.Binarywrite GetBinaryFile(sFullFileName)

>:

>: Function GetBinaryFile(ByVal sFileSpec)

>:       Const adTypeBinary = 1

>:       Dim objStream

>:       Set objStream = Server.Createobject("ADODB.Stream")

>:       objStream.Open

>:       objStream.Type = adTypeBinary

>:       objStream.LoadFromFile sFileSpec

>:       GetBinaryFile = objStream.read

>:       Set objStream = Nothing

>: End Function

>:

>:

>: This will use the ADODB Stream object to push contents of the file to the

>: browser. Since the content type is set to "application/x-unknown", the

>: browser will pop up a Save As dialog instead of opening the file in the

>: browser / plugin. The name defined by sFileName will be the name that is

>: displayed in the Save As dialog

>:

>:

>:

>: Hope this helps,

>:

>: Imar

>:





Message #11 by "Adeola" <aoadeyemo@h...> on Wed, 5 Dec 2001 10:33:00
Thanx alot guys,

Sorry my initial question was not clear enough, but i do appreciate your 

responses, and no knowledge is wasted. Imar was right about the question 

and once a gain thank you all.

Cheers

Ade'











> Yeah, no problem. I don't think his initial question was all that 

clear ;-) 

> Just saw this type of question come along quite a few times, so I 

figured 

> that was what he wanted.

> 

> Cheers,

> 

> Imar

> 

> 

> At 03:24 PM 12/4/2001 -0500, you wrote:

> >oh yeah.. that is true... sorry.. i guess i missed the point.. my

> >apalogies.. thanks imar!

> >

> >daniel

> >

> >--

> >-----------------------------

> >Daniel O'Dorisio

> >daniel@o...

> >www.odorisio-networks.com

> >-----------------------------

> >"Imar Spaanjaars" <Imar@S...> wrote in message

> >news:125928@a..._web_howto...

> >:

> >: Even with registered file types, like HTML and .DOC files, it IS 

possible

> >: to force both the download dialog and a filename.

> >:

> >: Try something like this (watch for wrapping):

> >:

> >: Response.Buffer = True

> >: sFullFileName = "C:\Attachments\File1.doc" ' file on your server

> >: sFileName = "File1.doc" ' filename the user will see

> >: Response.Contenttype="application/x-unknown"

> >: Response.Addheader "Content-Disposition", "attachment; filename=" &

> >chr(34)

> >: & sFileName & chr(34)

> >: Response.Binarywrite GetBinaryFile(sFullFileName)

> >:

> >: Function GetBinaryFile(ByVal sFileSpec)

> >:       Const adTypeBinary = 1

> >:       Dim objStream

> >:       Set objStream = Server.Createobject("ADODB.Stream")

> >:       objStream.Open

> >:       objStream.Type = adTypeBinary

> >:       objStream.LoadFromFile sFileSpec

> >:       GetBinaryFile = objStream.read

> >:       Set objStream = Nothing

> >: End Function

> >:

> >:

> >: This will use the ADODB Stream object to push contents of the file to 

the

> >: browser. Since the content type is set to "application/x-unknown", the

> >: browser will pop up a Save As dialog instead of opening the file in 

the

> >: browser / plugin. The name defined by sFileName will be the name that 

is

> >: displayed in the Save As dialog

> >:

> >:

> >:

> >: Hope this helps,

> >:

> >: Imar

> >:

> 

> 


  Return to Index