downloading more than 1 file in a single page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Adela Arpitha
    New Member
    • Jan 2008
    • 15

    downloading more than 1 file in a single page

    hi Frinny hope u'll notice my new doubt.
    how is this downloading option given in asp.net? im using asp.net 1.1 n c# as programming lang and sql server as back end.
    i actually tried it worked fine but only for a single file, in case if i give more than i file for download in the same page it gives the first file only for download it isnt considering the second one ....
    [code=cpp]
    private void Page_Load(objec t sender, System.EventArg s e)
    {
    Response.Clear( );
    string path = Request.QuerySt ring["fname"];
    System.IO.FileI nfo a = new System.IO.FileI nfo("c:/IP_Handbook.pdf ");
    Response.AddHea der("Content-Disposition","a ttachment;filen ame =" +a.Name);
    Response.AddHea der("Content-Length",a.Lengt h.ToString());
    Response.Conten tType="applicat ion/octate-stream";
    Response.WriteF ile(a.FullName) ;
    Response.End();
    }[/code]

    in the design page i have used 2 hyperlinks and in the url path i hv given the path of the pdf file (which i hv chosen here) - all these design is in webform1 and the code is in another webform2 - where there is nothing in design sheet.

    i want to use this technique for archieving monthly newsletter...pl ease help me.
    Last edited by Frinavale; May 2 '08, 04:29 PM. Reason: added [code] tags
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Originally posted by Adela Arpitha
    hi Frinny hope u'll notice my new doubt.
    how is this downloading option given in asp.net? im using asp.net 1.1 n c# as programming lang and sql server as back end.
    i actually tried it worked fine but only for a single file, in case if i give more than i file for download in the same page it gives the first file only for download it isnt considering the second one ....
    [code=cpp]
    private void Page_Load(objec t sender, System.EventArg s e)
    {
    Response.Clear( );
    string path = Request.QuerySt ring["fname"];
    System.IO.FileI nfo a = new System.IO.FileI nfo("c:/IP_Handbook.pdf ");
    Response.AddHea der("Content-Disposition","a ttachment;filen ame =" +a.Name);
    Response.AddHea der("Content-Length",a.Lengt h.ToString());
    Response.Conten tType="applicat ion/octate-stream";
    Response.WriteF ile(a.FullName) ;
    Response.End();
    }[/code]

    in the design page i have used 2 hyperlinks and in the url path i hv given the path of the pdf file (which i hv chosen here) - all these design is in webform1 and the code is in another webform2 - where there is nothing in design sheet.

    i want to use this technique for archieving monthly newsletter...pl ease help me.
    I've just done something similar with a reporting service I created.
    What I ended up doing was saving the the files to a temporary location on the web server, then once these were created I displayed a <div> in the middle of the screen listing hyperlinks to the files that are ready for downloading.

    I don't think that your method will allow you to let the user download more than one file at a time because it is writing the content directly to the Response.Write output stream stream instead of temporarily storing the data for download.

    I tend to like doing exactly what you are doing because it reduces the need to clean up the resources.

    If you're doing a newsletter...wh y not store a copy of the newsletter on the server and use a similar method to mine?

    There's no need to dynamically create a newsletter because they are the same for all users.

    -Frinny

    Comment

    • Adela Arpitha
      New Member
      • Jan 2008
      • 15

      #3
      hello frinny,
      hmmmm ya ur right i wil try doing it, but my project manager wants himself to get the direct access to upload his newsletter to the intranet site instead of taking the assistance of a system admin...
      he wants it to work something like this - whenever he wants to upload a newsletter ( usually in pdf format ) he will first login - this login right is given only for him and once he enters he must be able to add or delete files, thats it.
      any normal user can download files but cannot upload....and all the older newsletters must join the archieve automatically as and when the recent newsletter is added.
      thanks Frinny i will try it.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by Adela Arpitha
        hello frinny,
        hmmmm ya ur right i wil try doing it, but my project manager wants himself to get the direct access to upload his newsletter to the intranet site instead of taking the assistance of a system admin...
        he wants it to work something like this - whenever he wants to upload a newsletter ( usually in pdf format ) he will first login - this login right is given only for him and once he enters he must be able to add or delete files, thats it.
        any normal user can download files but cannot upload....and all the older newsletters must join the archieve automatically as and when the recent newsletter is added.
        thanks Frinny i will try it.
        So you're not even storing your newsletters into a database :)
        The files should already be on the server if your manager uploads them there.
        Sounds like this could work :)

        -Frinny

        Comment

        • Adela Arpitha
          New Member
          • Jan 2008
          • 15

          #5
          HI Frinny, hope ur doing good.
          i actully din understand wt u meant...u mean the code im using right now shud work?
          as i said it works but -
          1. for upload it browses the file and uploads but works only with local drives and i donno wt to use or which asp.net ctrl to use in order to upload the selected file onto the webform...it needs database right...
          2. for download only 1 hyperlink works fine where the designing part will be in webform1 and the coding part in webfrom2 which shud not have any design in it. In this case i will have to open n code in different webforms for each downloadable file na??
          wt to do wt to do?

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            Originally posted by Adela Arpitha
            HI Frinny, hope ur doing good.
            i actully din understand wt u meant...u mean the code im using right now shud work?
            as i said it works but -
            1. for upload it browses the file and uploads but works only with local drives and i donno wt to use or which asp.net ctrl to use in order to upload the selected file onto the webform...it needs database right...
            2. for download only 1 hyperlink works fine where the designing part will be in webform1 and the coding part in webfrom2 which shud not have any design in it. In this case i will have to open n code in different webforms for each downloadable file na??
            wt to do wt to do?
            No the code you have right now will only let you download one file at a time.
            I was saying that this could work because I thought that your manager was uploading files to the web server already; in this case it would be easy to just reference them using hyperlinks.

            To upload files to the server you use the FileUpload Control. You can upload the file and save it directly to a database, or simply save it to a folder on your web server that will let other people download it through a browser...

            -Frinny

            Comment

            • Adela Arpitha
              New Member
              • Jan 2008
              • 15

              #7
              :) :) thanks a lot Frinny il check out with the company's system admin and c if they can help me do this way.....thanks so much again.

              Comment

              Working...