Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14

Thread: Download

  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Download

    How do you set up a link so that a file is downloaded when it is clicked.

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    North of Boston
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You usually have to right click on a link to save the file.

    You you could do some form of onclick event to handle it.
    bedardinc.com
    A+,Network+, MCP W2K
    Sites I have worked on
    patriotsweekly.com
    smileysbookstore.com

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    <a href="file.ext">Click here to download</a>

    <edit>Of course the above depends on what type of file you want to be downloaded.</edit>

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    If you have access to the .htaccess file:
    http://www.javascriptkit.com/howto/htaccess9.shtml


  • #5
    New Coder
    Join Date
    Jun 2002
    Location
    yorkshire, uk
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm also looking for something similar, i.e. a link that saves a file to disk instead of the file being opened by the browser. is there some easy way to do this? can js replicate the browser's file > save command or is there a setting in the <a> tag that might work? or is it another of these things that can't be done without server-side access? i don't have access to .htaccess or any server-side languages.
    neil.c

  • #6
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Can;t you just put it in a zip file?

  • #7
    New Coder
    Join Date
    Jun 2002
    Location
    yorkshire, uk
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    fair enough but id already thought of that. but what about that winzip plugin that opens zips immediately in a temp folder?
    its not exactly essential that i can do this, i just thought there might be a way to save stuff.
    neil.c

  • #8
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    I believe IE has some sort of behavior you can use that forces the File Save As box... I'd search msdn.microsoft.com for it.

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Posts
    262
    Thanks
    0
    Thanked 0 Times in 0 Posts

    This would work

    If you don't mind the material being saved as a .htm document then this could be used -

    In the <head> tag put

    <script language="JavaScript" type="text/JavaScript">
    var now = false;
    function saveIt(){
    if (document.execCommand){
    if (now){document.execCommand("SaveAs");}
    }
    }
    </script>

    In the <body> tag put
    <body onLoad="now=true">

    The link on the page to be saved put

    <a href="javascript:;" onClick="saveIt();">

    <p>Save This Page</a></p>

    I saw this a few days ago from another post on this site by boxer_1! Credit where its due.

    I would ask, what are the document types you want to allow users to download? .doc .xls .pdf .jpg .gif?
    This would have some bearing on other possible download methods/solutions.

    EG - Save doscuments as .pdf Yep, you need the software but I'd say a majority of users have the plugin so viewing is straight fwd.
    You could post instructions for the saving of the documents and hey presto. Done.
    Last edited by tommysphone; 06-27-2002 at 08:20 AM.

  • #10
    New Coder
    Join Date
    Jun 2002
    Location
    yorkshire, uk
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok what about .docs and .jpegs? i can hardly put a link on them, no matter where the script is. and i'd rather have it so that the files are downloaded and saved without opening - like doing a right-click on link > save target as.

    thanks for the .html one, this will be useful somewhere.

    i'll look on msdn to see if IE has anything like this.
    neil.c

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Location
    Conwy. UK
    Posts
    122
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The only reason a file is opened by an app is because the extention is recognised. If you put a totaly wierd extention that would not be recognised then it would download to disc. On the download page just put instructions on how to rename once downloaded.
    An answer needs a question just as much as a question needs an answer. Deep eh!

  • #12
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    If you don't want to require that your clients have winzip or compatible decompressor, WinZip does make a program that will let you convert .zip files to .exe files that can automatically extract.
    OracleGuy

  • #13
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, I've sorted out the problem now.

  • #14
    Regular Coder
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    183
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by practisevoodoo
    Thanks, I've sorted out the problem now.
    How'd you do it, then? Just in case someone else has your problem and searches the forum for it Plus I'm curious
    Offtone.com - In the works...


  •  

    Posting Permissions

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