prompt "Save as" dialog for image

Discussion in 'ASP General' started by dave, Nov 19, 2004.

  1. dave

    dave Guest

    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!!!
     
    dave, Nov 19, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > 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], Nov 19, 2004
    #2
    1. Advertising

  3. dave

    dave Guest

    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:...
    > 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" <> wrote in message
    > news:%...
    > > 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!!!
    > >
    > >

    >
    >
     
    dave, Nov 19, 2004
    #3
  4. 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" <> wrote in message
    news:...
    > 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:...
    >> 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" <> wrote in message
    >> news:%...
    >> > 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], Nov 19, 2004
    #4
  5. dave

    dave Guest

    yeh man, it worked
    thanx for help
    dev

    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:...
    > 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" <> wrote in message
    > news:...
    > > 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:...
    > >> 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" <> wrote in message
    > >> news:%...
    > >> > 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!!!
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
     
    dave, Nov 19, 2004
    #5
  6. dave

    dave Guest

    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:...
    > 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" <> wrote in message
    > news:...
    > > 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:...
    > >> 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" <> wrote in message
    > >> news:%...
    > >> > 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!!!
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
     
    dave, Nov 19, 2004
    #6
  7. Do you have evidence that suggests that it doesn't?

    Ray at home

    "dave" <> wrote in message
    news:...
    > just one question
    > how do i make this code to work with most common all browser
    > dev
     
    Ray Costanzo [MVP], Nov 19, 2004
    #7
  8. dave

    dave Guest

    no..but
    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
    message news:#...
    > Do you have evidence that suggests that it doesn't?
    >
    > Ray at home
    >
    > "dave" <> wrote in message
    > news:...
    > > just one question
    > > how do i make this code to work with most common all browser
    > > dev

    >
    >
     
    dave, Nov 19, 2004
    #8
  9. dave

    dave Guest

    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:#...
    > Do you have evidence that suggests that it doesn't?
    >
    > Ray at home
    >
    > "dave" <> wrote in message
    > news:...
    > > just one question
    > > how do i make this code to work with most common all browser
    > > dev

    >
    >
     
    dave, Nov 19, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr Gordonz

    Prompt user with OpenFile dialog

    Mr Gordonz, Aug 6, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    427
    Mr Gordonz
    Aug 6, 2003
  2. gaurav kashyap
    Replies:
    2
    Views:
    623
    gaurav kashyap
    Oct 30, 2008
  3. gaurav kashyap
    Replies:
    3
    Views:
    689
    gaurav kashyap
    Oct 31, 2008
  4. Mel
    Replies:
    10
    Views:
    3,130
    Sailaja Appi
    Feb 13, 2009
  5. FAQ server
    Replies:
    44
    Views:
    843
Loading...

Share This Page