dcsimg
www.webdeveloper.com
Results 1 to 11 of 11

Thread: download a file from a popup window

  1. #1
    Join Date
    Oct 2003
    Posts
    183

    download a file from a popup window

    Hello,

    I would be really glad if someone could help me with this little problem.

    I have a site were visitors can download songs that I have made and I want to count how many times every song has been downloaded. I thought that I could do something like this...
    I have a page with links to my songs. When a visitor clicks on a link they will be redirected to a page lets say bla.jsp?id=1
    On bla.jsp I do a request.getParameter("id") and make a connection to a database were all my "songs" (the name of the songs) are stored with the same "id" as on the page.... Now I have solved the "count problem"

    Now I want from bla.jsp open a new little window, above my bla.jsp, which will download current song. Lets say that my track is called "hello.mp3" with id=1. My songs are stored on my webbserver and not in a database in a catalogu called "musik" (musik/hello.mp3).

    How do I do that?

    Thanks in advance// D_S

  2. #2
    Join Date
    Nov 2002
    Location
    Nashua, NH
    Posts
    3,195
    Just do a simple response redirect once you incremented your counter, why pollute screen with extra windows and depend on popup blockers.

  3. #3
    Join Date
    Oct 2003
    Posts
    183
    Hello,

    Thanks for your answer Vladdy... you are right, you have to excuse my lack of knowledge but....
    How do I redirect....will that create a new window in that frame which the link was clicked or will it just create a "downloadwindow" (that would be the best).

    Thanks in advance!

  4. #4
    Join Date
    Nov 2002
    Location
    Nashua, NH
    Posts
    3,195
    If the file is sent with MIME type that can not be displayed by browser, the Download/Execute window will show. If you check the "Download Evaluation Code" functionality on my site - that is what happening, when the user submits the form, the request is logged and then redirection is done.
    I'm not sure how to do the redirection in jsp

  5. #5
    Join Date
    Oct 2003
    Posts
    183
    Hello Vladdy,

    Ok, I dont have a clue if the file is sent with MIME, the mp3 file is on a webserver. There is no forms in this downloadprocess.

    I thought that because that the jsp-page is created on the serverside and is send back to the client I could have a <body onload="viewWindow(id)> where id is my songindex.
    Then in my vieWindow(id) I check index and create a new little downloadwindow that download correct song.

    But I really dont know how to create that kind of window that downloads a file automaticly.

    Thanks again.

  6. #6
    Join Date
    Nov 2002
    Location
    Nashua, NH
    Posts
    3,195
    All files are send with MIME type, the question is what is it.
    There does not have to be a form:

    <a href="server.script?file=mySong.mp3">Download mySong.mp3</a>

    server.script :
    // Increment the counter
    // redirect to GET['file']

    I do not know jsp so I can not help you with implementation, but I do know this approach works just fine with ASP and PHP - it does not matter what server side language is - you are relying on HTTP protocol for redirection.

  7. #7
    Join Date
    Oct 2003
    Posts
    183
    Ok, I'll try it...

    Thank you very much for you help!

  8. #8
    Join Date
    Nov 2002
    Location
    Nashua, NH
    Posts
    3,195
    You are welcome.

  9. #9
    Join Date
    Jul 2003
    Location
    Boston Area, Massachusetts
    Posts
    3,489
    Moved to the "other" section as this isn't JavaScript-related. As for sending HTTP headers, you might consider looking into the response.addHeader method.
    Last edited by fredmv; 05-10-2004 at 11:02 PM.

  10. #10
    Join Date
    May 2004
    Posts
    10
    sounds like a flash game theif to me.

  11. #11
    Join Date
    Aug 2003
    Posts
    1,576
    Originally posted by freexbay
    sounds like a flash game theif to me.
    what??

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles