Connecting Tech Pros Worldwide Forums | Help | Site Map

prompt "Save as" dialog for image

dave
Guest
 
Posts: n/a
#1: Jul 22 '05
Hi there
I'm trying to force save as dialogue using this code in download.asp..but
when it runs it prompts for download.asp to save or open.

code snippet (from aspfaq.com)

Response.ContentType = "application/x-unknown" ' arbitrary
fn = "wallpaper_1_1.jpg"
Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
FPath = Server.MapPath("wallpaper") & fn
Response.AddHeader "Content-Disposition","attachment; filename=" & fn

Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(FPath)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing


I want this page to prompt save image option, not page itself.

Any help would be appreciated!!!



Ray Costanzo [MVP]
Guest
 
Posts: n/a
#2: Jul 22 '05

re: prompt "Save as" dialog for image


Are you accessing the page via http? Like, you're going to
http://localhost/download.asp as opposed to C:\Inetpub\wwwroot\download.asp?

Ray at work


"dave" <forged@foo.netREMOVE> wrote in message
news:%232ZC2QdzEHA.2804@TK2MSFTNGP15.phx.gbl...[color=blue]
> Hi there
> I'm trying to force save as dialogue using this code in download.asp..but
> when it runs it prompts for download.asp to save or open.
>
> code snippet (from aspfaq.com)
>
> Response.ContentType = "application/x-unknown" ' arbitrary
> fn = "wallpaper_1_1.jpg"
> Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
> FPath = Server.MapPath("wallpaper") & fn
> Response.AddHeader "Content-Disposition","attachment; filename=" & fn
>
> Set adoStream = CreateObject("ADODB.Stream")
> adoStream.Open()
> adoStream.Type = 1
> adoStream.LoadFromFile(FPath)
> Response.BinaryWrite adoStream.Read()
> adoStream.Close
> Set adoStream = Nothing
>
>
> I want this page to prompt save image option, not page itself.
>
> Any help would be appreciated!!!
>
>[/color]


dave
Guest
 
Posts: n/a
#3: Jul 22 '05

re: prompt "Save as" dialog for image


yes
i m accessling thru http:
http://localhost/download.asp
and its asking me open, save,cancel options
dave

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:Ofg8BWdzEHA.1300@TK2MSFTNGP14.phx.gbl...[color=blue]
> Are you accessing the page via http? Like, you're going to
> http://localhost/download.asp as opposed to[/color]
C:\Inetpub\wwwroot\download.asp?[color=blue]
>
> Ray at work
>
>
> "dave" <forged@foo.netREMOVE> wrote in message
> news:%232ZC2QdzEHA.2804@TK2MSFTNGP15.phx.gbl...[color=green]
> > Hi there
> > I'm trying to force save as dialogue using this code in[/color][/color]
download.asp..but[color=blue][color=green]
> > when it runs it prompts for download.asp to save or open.
> >
> > code snippet (from aspfaq.com)
> >
> > Response.ContentType = "application/x-unknown" ' arbitrary
> > fn = "wallpaper_1_1.jpg"
> > Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
> > FPath = Server.MapPath("wallpaper") & fn
> > Response.AddHeader "Content-Disposition","attachment; filename=" & fn
> >
> > Set adoStream = CreateObject("ADODB.Stream")
> > adoStream.Open()
> > adoStream.Type = 1
> > adoStream.LoadFromFile(FPath)
> > Response.BinaryWrite adoStream.Read()
> > adoStream.Close
> > Set adoStream = Nothing
> >
> >
> > I want this page to prompt save image option, not page itself.
> >
> > Any help would be appreciated!!!
> >
> >[/color]
>
>[/color]


Ray Costanzo [MVP]
Guest
 
Posts: n/a
#4: Jul 22 '05

re: prompt "Save as" dialog for image


Do you have an On Error Resume Next? Well, regardless, a couple of changes
will be necessary.

When you Response.write FPath, did you notice that there was no \ between
the directory name and the filename? You'll need that. Also, make sure you
do not leave the Response.Write code in there when you get this working.
Try this code:

Response.ContentType = "application/x-unknown" ' arbitrary
fn = "wallpaper_1_1.jpg"
'Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
FPath = Server.MapPath("wallpaper") & "\" & fn
Response.AddHeader "Content-Disposition","attachment; filename=" & fn

Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(FPath)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing

Ray at home

"dave" <forged@foo.netREMOVE> wrote in message
news:eQbeeqdzEHA.1652@TK2MSFTNGP11.phx.gbl...[color=blue]
> yes
> i m accessling thru http:
> http://localhost/download.asp
> and its asking me open, save,cancel options
> dave
>
> "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
> message news:Ofg8BWdzEHA.1300@TK2MSFTNGP14.phx.gbl...[color=green]
>> Are you accessing the page via http? Like, you're going to
>> http://localhost/download.asp as opposed to[/color]
> C:\Inetpub\wwwroot\download.asp?[color=green]
>>
>> Ray at work
>>
>>
>> "dave" <forged@foo.netREMOVE> wrote in message
>> news:%232ZC2QdzEHA.2804@TK2MSFTNGP15.phx.gbl...[color=darkred]
>> > Hi there
>> > I'm trying to force save as dialogue using this code in[/color][/color]
> download.asp..but[color=green][color=darkred]
>> > when it runs it prompts for download.asp to save or open.
>> >
>> > code snippet (from aspfaq.com)
>> >
>> > Response.ContentType = "application/x-unknown" ' arbitrary
>> > fn = "wallpaper_1_1.jpg"
>> > Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
>> > FPath = Server.MapPath("wallpaper") & fn
>> > Response.AddHeader "Content-Disposition","attachment; filename=" &
>> > fn
>> >
>> > Set adoStream = CreateObject("ADODB.Stream")
>> > adoStream.Open()
>> > adoStream.Type = 1
>> > adoStream.LoadFromFile(FPath)
>> > Response.BinaryWrite adoStream.Read()
>> > adoStream.Close
>> > Set adoStream = Nothing
>> >
>> >
>> > I want this page to prompt save image option, not page itself.
>> >
>> > Any help would be appreciated!!!
>> >
>> >[/color]
>>
>>[/color]
>
>[/color]


dave
Guest
 
Posts: n/a
#5: Jul 22 '05

re: prompt "Save as" dialog for image


yeh man, it worked
thanx for help
dev

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:egtV0kezEHA.3588@TK2MSFTNGP14.phx.gbl...[color=blue]
> Do you have an On Error Resume Next? Well, regardless, a couple of[/color]
changes[color=blue]
> will be necessary.
>
> When you Response.write FPath, did you notice that there was no \ between
> the directory name and the filename? You'll need that. Also, make sure[/color]
you[color=blue]
> do not leave the Response.Write code in there when you get this working.
> Try this code:
>
> Response.ContentType = "application/x-unknown" ' arbitrary
> fn = "wallpaper_1_1.jpg"
> 'Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
> FPath = Server.MapPath("wallpaper") & "\" & fn
> Response.AddHeader "Content-Disposition","attachment; filename=" & fn
>
> Set adoStream = CreateObject("ADODB.Stream")
> adoStream.Open()
> adoStream.Type = 1
> adoStream.LoadFromFile(FPath)
> Response.BinaryWrite adoStream.Read()
> adoStream.Close
> Set adoStream = Nothing
>
> Ray at home
>
> "dave" <forged@foo.netREMOVE> wrote in message
> news:eQbeeqdzEHA.1652@TK2MSFTNGP11.phx.gbl...[color=green]
> > yes
> > i m accessling thru http:
> > http://localhost/download.asp
> > and its asking me open, save,cancel options
> > dave
> >
> > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
> > message news:Ofg8BWdzEHA.1300@TK2MSFTNGP14.phx.gbl...[color=darkred]
> >> Are you accessing the page via http? Like, you're going to
> >> http://localhost/download.asp as opposed to[/color]
> > C:\Inetpub\wwwroot\download.asp?[color=darkred]
> >>
> >> Ray at work
> >>
> >>
> >> "dave" <forged@foo.netREMOVE> wrote in message
> >> news:%232ZC2QdzEHA.2804@TK2MSFTNGP15.phx.gbl...
> >> > Hi there
> >> > I'm trying to force save as dialogue using this code in[/color]
> > download.asp..but[color=darkred]
> >> > when it runs it prompts for download.asp to save or open.
> >> >
> >> > code snippet (from aspfaq.com)
> >> >
> >> > Response.ContentType = "application/x-unknown" ' arbitrary
> >> > fn = "wallpaper_1_1.jpg"
> >> > Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
> >> > FPath = Server.MapPath("wallpaper") & fn
> >> > Response.AddHeader "Content-Disposition","attachment; filename=" &
> >> > fn
> >> >
> >> > Set adoStream = CreateObject("ADODB.Stream")
> >> > adoStream.Open()
> >> > adoStream.Type = 1
> >> > adoStream.LoadFromFile(FPath)
> >> > Response.BinaryWrite adoStream.Read()
> >> > adoStream.Close
> >> > Set adoStream = Nothing
> >> >
> >> >
> >> > I want this page to prompt save image option, not page itself.
> >> >
> >> > Any help would be appreciated!!!
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]


dave
Guest
 
Posts: n/a
#6: Jul 22 '05

re: prompt "Save as" dialog for image


just one question
how do i make this code to work with most common all browser
dev

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:egtV0kezEHA.3588@TK2MSFTNGP14.phx.gbl...[color=blue]
> Do you have an On Error Resume Next? Well, regardless, a couple of[/color]
changes[color=blue]
> will be necessary.
>
> When you Response.write FPath, did you notice that there was no \ between
> the directory name and the filename? You'll need that. Also, make sure[/color]
you[color=blue]
> do not leave the Response.Write code in there when you get this working.
> Try this code:
>
> Response.ContentType = "application/x-unknown" ' arbitrary
> fn = "wallpaper_1_1.jpg"
> 'Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
> FPath = Server.MapPath("wallpaper") & "\" & fn
> Response.AddHeader "Content-Disposition","attachment; filename=" & fn
>
> Set adoStream = CreateObject("ADODB.Stream")
> adoStream.Open()
> adoStream.Type = 1
> adoStream.LoadFromFile(FPath)
> Response.BinaryWrite adoStream.Read()
> adoStream.Close
> Set adoStream = Nothing
>
> Ray at home
>
> "dave" <forged@foo.netREMOVE> wrote in message
> news:eQbeeqdzEHA.1652@TK2MSFTNGP11.phx.gbl...[color=green]
> > yes
> > i m accessling thru http:
> > http://localhost/download.asp
> > and its asking me open, save,cancel options
> > dave
> >
> > "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
> > message news:Ofg8BWdzEHA.1300@TK2MSFTNGP14.phx.gbl...[color=darkred]
> >> Are you accessing the page via http? Like, you're going to
> >> http://localhost/download.asp as opposed to[/color]
> > C:\Inetpub\wwwroot\download.asp?[color=darkred]
> >>
> >> Ray at work
> >>
> >>
> >> "dave" <forged@foo.netREMOVE> wrote in message
> >> news:%232ZC2QdzEHA.2804@TK2MSFTNGP15.phx.gbl...
> >> > Hi there
> >> > I'm trying to force save as dialogue using this code in[/color]
> > download.asp..but[color=darkred]
> >> > when it runs it prompts for download.asp to save or open.
> >> >
> >> > code snippet (from aspfaq.com)
> >> >
> >> > Response.ContentType = "application/x-unknown" ' arbitrary
> >> > fn = "wallpaper_1_1.jpg"
> >> > Response.write "<br>" & Server.MapPath("wallpaper") & "<br>"
> >> > FPath = Server.MapPath("wallpaper") & fn
> >> > Response.AddHeader "Content-Disposition","attachment; filename=" &
> >> > fn
> >> >
> >> > Set adoStream = CreateObject("ADODB.Stream")
> >> > adoStream.Open()
> >> > adoStream.Type = 1
> >> > adoStream.LoadFromFile(FPath)
> >> > Response.BinaryWrite adoStream.Read()
> >> > adoStream.Close
> >> > Set adoStream = Nothing
> >> >
> >> >
> >> > I want this page to prompt save image option, not page itself.
> >> >
> >> > Any help would be appreciated!!!
> >> >
> >> >
> >>
> >>[/color]
> >
> >[/color]
>
>[/color]


Ray Costanzo [MVP]
Guest
 
Posts: n/a
#7: Jul 22 '05

re: prompt "Save as" dialog for image


Do you have evidence that suggests that it doesn't?

Ray at home

"dave" <forged@foo.netREMOVE> wrote in message
news:OGiw5rezEHA.3004@TK2MSFTNGP10.phx.gbl...[color=blue]
> just one question
> how do i make this code to work with most common all browser
> dev[/color]


dave
Guest
 
Posts: n/a
#8: Jul 22 '05

re: prompt "Save as" dialog for image


no..but
"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:#by4mefzEHA.2016@TK2MSFTNGP15.phx.gbl...[color=blue]
> Do you have evidence that suggests that it doesn't?
>
> Ray at home
>
> "dave" <forged@foo.netREMOVE> wrote in message
> news:OGiw5rezEHA.3004@TK2MSFTNGP10.phx.gbl...[color=green]
> > just one question
> > how do i make this code to work with most common all browser
> > dev[/color]
>
>[/color]


dave
Guest
 
Posts: n/a
#9: Jul 22 '05

re: prompt "Save as" dialog for image


no but
http://www.aspfaq.com/show.asp?id=2161
in last lines of articles says u might have to change addheader lines to get
correct filename...
thts wht puzzling me
dave

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:#by4mefzEHA.2016@TK2MSFTNGP15.phx.gbl...[color=blue]
> Do you have evidence that suggests that it doesn't?
>
> Ray at home
>
> "dave" <forged@foo.netREMOVE> wrote in message
> news:OGiw5rezEHA.3004@TK2MSFTNGP10.phx.gbl...[color=green]
> > just one question
> > how do i make this code to work with most common all browser
> > dev[/color]
>
>[/color]


Closed Thread


Similar ASP / Active Server Pages bytes