Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Saving/Downloading file

Saving/Downloading file

Scheduled Pinned Locked Moved ASP.NET
helpsysadminsecurity
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Plunging_Falcon
    wrote on last edited by
    #1

    Hello, I am trying to create a web application where the client has the option to save a file onto his computer (with his permission), but I haven't been able to find a solution for that problem. I suspect it might be impossible for security reasons. If that can't be done, I would like to save the file on the server, but still allow the client a SaveFileDialog to choose the location on the server, and I haven't been able to find a solution for that too. I'd appreciate any help, Alex.:confused:

    A 1 Reply Last reply
    0
    • P Plunging_Falcon

      Hello, I am trying to create a web application where the client has the option to save a file onto his computer (with his permission), but I haven't been able to find a solution for that problem. I suspect it might be impossible for security reasons. If that can't be done, I would like to save the file on the server, but still allow the client a SaveFileDialog to choose the location on the server, and I haven't been able to find a solution for that too. I'd appreciate any help, Alex.:confused:

      A Offline
      A Offline
      Albert Pascual
      wrote on last edited by
      #2

      Why can't you just send a file into the Client Browser? Save the file into the server and then just do Response.Redirect(filename); In the client browser will display, Open/Save/Cancel dialog box. Or you can do this, this is an example in PDF, make sure you change the type for different file formats: string sFile = "sample.pdf"; Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/pdf"; try { Response.WriteFile( MapPath( sFile ) ); Response.Flush(); Response.Close(); } catch { Response.ClearContent(); }

      P 1 Reply Last reply
      0
      • A Albert Pascual

        Why can't you just send a file into the Client Browser? Save the file into the server and then just do Response.Redirect(filename); In the client browser will display, Open/Save/Cancel dialog box. Or you can do this, this is an example in PDF, make sure you change the type for different file formats: string sFile = "sample.pdf"; Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "Application/pdf"; try { Response.WriteFile( MapPath( sFile ) ); Response.Flush(); Response.Close(); } catch { Response.ClearContent(); }

        P Offline
        P Offline
        Plunging_Falcon
        wrote on last edited by
        #3

        Thanks, but I found a better way to do this using javascript: string script = ""; script += ""; script += "function save() { "; script += "window_handle = window.open('"+filename+"','something');"; script += "window_handle.document.execCommand(\"SaveAs\");"; script += "window_handle.close(); }"; script += "save();"; script += ""; Page.RegisterClientScriptBlock("anything",script); Alex.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups