Results 1 to 11 of 11

Thread: File Download link

  1. #1
    Join Date
    Sep 2005

    File Download link

    What i need, is when the user clicks on a link to download a file it opens the standard file save as / open dialog box. The user can then choose a location to save the file and carry on.


  2. #2
    Join Date
    Apr 2005
    Bathurst, NSW, Australia
    what sort of file. if you just link to the file then it should automatically prompt this, but if its a webfile like an image or something like that then you can zip it and then just link to the zip, or even add a little note "to download right click and save as"

  3. #3
    Join Date
    Sep 2005
    The file is an .mpg. At the moment if i select the link no file dialog box appears. I wondered if there was any java code or something to prompt this. Thanks for your help!

  4. #4
    Join Date
    Sep 2005

    Use a content-disposition header

    I had the same problem with a CSV file--I needed the browser to save it to the client's disk, not open it as a spreadsheet. The trick is to include this HTTP header:
    Content-disposition: attachment; filename=<yourfile.mpg>;

    When Internet Explorer sees this, it presents a file download dialog instead of rendering the content. It works for me with Netscape 7 too, as long as popus are enabled.

    See "How To Raise a "File Download" Dialog Box for a Known MIME Type"
    at http://support.microsoft.com/default...0519#appliesto

    If you're an IIS/.NET shop, check "How do I prompt a 'Save As' dialog for an accepted MIME type?" at http://aspfaq.com/show.asp?id=2161

    If you're writing servlets, look at http://www.jguru.com/faq/view.jsp?EID=502939

  5. #5
    Join Date
    Sep 2005

    content disposition

    Where do you put this :

    Content-disposition: attachment; filename=<yourfile.mpg>;

    Is it javascript code ?

    Could you give an example ?


  6. #6
    Join Date
    Sep 2005
    if (file_exists($file) ) {  
    	   header('Content-type: application/force-download');
    	   header('Content-Transfer-Encoding: Binary');
    	   header('Content-length: '.filesize($file));
    	   header('Content-disposition: attachment;
    	} else {
    	   echo 'No file with this name for download.';
    It will display the file download as soon as the page loads.

  7. #7
    Join Date
    Oct 2005

    i actually need to do the exact same thing, except...

    i have a button on my jsp.. let call it "Generate"....
    what i would like to do is.. when the user clicks generate,
    a file is generated (the jsp is displaying a spreadsheet in html, and a csv file
    is generated).. once this file is generated.. i want the user to be prompted
    via a pop-up box and is asked where to save this file...

    any ideas?


  8. #8
    Join Date
    May 2007

    File Download Dialog

    Hi Folks

    I too have a Query relative to this thread

    In a JSP page of my site I am showing the .csv file links. When user clicks the link the file download dialog box use to appear to let the user download the file. This was working fine with IE 5.5. But user have shifted their browser version from IE5.5 to IE6.0. And now user do not see the same old download dialog box. The .csv file is getting open in the browser itself. Can anybody help me out? Because the same code was working with IE5.5 but it is not working with IE6.0. What may be the reason behind this?

    I used the Below lines in my JSP page for displaying File Dialog

    response.setHeader("Content-Disposition","attachment; filename="+fileName+";");


  9. #9
    Join Date
    Jul 2007
    I have a similar problem, I tried your suggestions for "Content-disposition" but didn't change any thing.
    I explain my prblem, I have a link on a jsp page normaly when you click the link you get the dialog box (open/save/cancel)
    with firefox it gives the dialog box but with IE it doesn't give the dialog box all the times just for some files
    ,I have different files (.pdf), (.rtf), (.doc), with (.pdf)(.rtf)no problem but with (.doc) files doesn't work for all
    my link is like this:
    <%if(row.get("cv_id") == null){%><fmt:message key="club.field.yes_no0" bundle="$msg"/><%}
    <a href="<%=request.getContextPath()%>/tmp/<%=row.get("filename")%>?id=<%=row.get("employee_id")%>" class="gray"><fmt:message key="club.field.yes_no1" bundle="$msg"/></a>
    any ideas please.
    Last edited by DevSA; 08-02-2007 at 01:09 PM.

  10. #10
    Join Date
    May 2007

    Red face To Display File Download Dialog

    In the JSP page put the following two lines of code inside a scriptlet to display a open/save dialog box, which helps the user to choose the location to save the file.

    response.setHeader("Content-Disposition","attachment; filename="<FILENAME>";");

    The setContentType() paramater is the MIME extn.

    Hope this will help u to display the DownloadDialog in ur application.


  11. #11
    Join Date
    Jul 2007
    Thanks for your reply VIVATHA, but it didn`t change anything, still not working.
    other ideas.

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13213 seconds
  • Memory Usage 2,944KB
  • Queries Executed 13 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (11)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (11)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates