Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-21-2002, 10:06 PM   PM User | #1
practisevoodoo
New to the CF scene

 
Join Date: Jun 2002
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
practisevoodoo is an unknown quantity at this point
Download

How do you set up a link so that a file is downloaded when it is clicked.
practisevoodoo is offline   Reply With Quote
Old 06-21-2002, 10:19 PM   PM User | #2
prezbedard
New Coder

 
Join Date: Jun 2002
Location: North of Boston
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
prezbedard is an unknown quantity at this point
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
prezbedard is offline   Reply With Quote
Old 06-22-2002, 05:13 AM   PM User | #3
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
<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>
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 06-22-2002, 05:17 AM   PM User | #4
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
If you have access to the .htaccess file:
http://www.javascriptkit.com/howto/htaccess9.shtml

__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 06-26-2002, 08:28 PM   PM User | #5
neil.c
New Coder

 
Join Date: Jun 2002
Location: yorkshire, uk
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
neil.c is an unknown quantity at this point
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
neil.c is offline   Reply With Quote
Old 06-26-2002, 08:31 PM   PM User | #6
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
Can;t you just put it in a zip file?
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 06-26-2002, 08:41 PM   PM User | #7
neil.c
New Coder

 
Join Date: Jun 2002
Location: yorkshire, uk
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
neil.c is an unknown quantity at this point
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
neil.c is offline   Reply With Quote
Old 06-27-2002, 12:40 AM   PM User | #8
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
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.
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Old 06-27-2002, 08:11 AM   PM User | #9
tommysphone
Regular Coder

 
Join Date: Jun 2002
Posts: 262
Thanks: 0
Thanked 0 Times in 0 Posts
tommysphone is an unknown quantity at this point
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..
tommysphone is offline   Reply With Quote
Old 06-27-2002, 11:23 AM   PM User | #10
neil.c
New Coder

 
Join Date: Jun 2002
Location: yorkshire, uk
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
neil.c is an unknown quantity at this point
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
neil.c is offline   Reply With Quote
Old 06-27-2002, 11:42 PM   PM User | #11
Jeepers
Regular Coder

 
Join Date: Jun 2002
Location: Conwy. UK
Posts: 122
Thanks: 0
Thanked 0 Times in 0 Posts
Jeepers is an unknown quantity at this point
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!
Jeepers is offline   Reply With Quote
Old 06-28-2002, 04:55 AM   PM User | #12
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,042
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
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
oracleguy is offline   Reply With Quote
Old 07-15-2002, 12:10 PM   PM User | #13
practisevoodoo
New to the CF scene

 
Join Date: Jun 2002
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
practisevoodoo is an unknown quantity at this point
Thanks, I've sorted out the problem now.
practisevoodoo is offline   Reply With Quote
Old 07-15-2002, 05:35 PM   PM User | #14
SYP}{ER
Regular Coder

 
Join Date: Jun 2002
Location: Ontario, Canada
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
SYP}{ER is an unknown quantity at this point
Quote:
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...
SYP}{ER is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:19 PM.


Advertisement
Log in to turn off these ads.