Web Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignWeb Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 2nd, 2003, 09:00 PM
robsta robsta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Pacific NW, U.S.A.
Posts: 146 robsta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Script » Download file via hyperlink

Hello!

I'm putting together a page that'll include a link to a freebie .tif file (stored on the server) that my site visitor can download upon completing a brief questionnaire. Other than «right-clicking», is there a script that will automatically launch a «Save file» dialog box so that they can download the file? js? php?

Thanks,
Robsta
__________________
http://www.fond-regards.com

Reply With Quote
  #2  
Old December 2nd, 2003, 11:12 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
From what I understand of your question, there's two common options. Either a specific file download page, or javascript.



You could always create one of those traditional download pages, something like what Download.com uses... the download starts automatically when the page loads, as well as a link that reads "If the download doesn't start, click here"... Download.com actually uses an <IFRAME> to popup the dialog...

<iframe height="0" width="0" src="http://localhost/some.file"></iframe>



You could also do a javascript onload (or even onclick) function, but not all users have javascript enabled...

<body onload="javascript:window.location.href='http://localhost/some.file';">

[*edit* for some reason it looks like i'm getting a space in the word javascript from my example above... make sure you don't print that]

One problem you may encounter is that if a user's browser is setup to display the TIFF mime type (image/tiff) then the user will see the actual image, as opposed to seeing the download prompt.

Reply With Quote
  #3  
Old December 3rd, 2003, 05:02 PM
robsta robsta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Pacific NW, U.S.A.
Posts: 146 robsta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thanks for the code!! I'll probably go the js route. Also, thanks for the *edit* on javascript (all one word). I knew that, but I probably would have copied/pasted as is...

Robsta

Reply With Quote
  #4  
Old December 4th, 2003, 12:34 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
heh, its strange...
when I edited the the post, it displays as javascript (all one word), but when its read through the forum there's a space... and when i copied it from theforum there's a space... maybe i'm just blind... =)


I'm pretty sure that the javascript code i provided is cross-browser, but I haven't tried it... also remember, some users may have not javascript enabled, so an additional/alternate method is a good idea

Reply With Quote
  #5  
Old December 4th, 2003, 02:35 PM
robsta robsta is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Pacific NW, U.S.A.
Posts: 146 robsta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Hi!

It's probably because I started the thread on a Mac

Yes, I'll post some «Right-click» info so they can download the file that way if need be. I've not had a chance to implement it yet - I'll let you know how it turns out.

Thanks again,
Robsta

Reply With Quote
  #6  
Old January 21st, 2008, 05:30 PM
fiercephoenix fiercephoenix is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2008
Posts: 1 fiercephoenix User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 23 sec
Reputation Power: 0
Exclamation Pulling out my hair

Ok here we go I used the same code here in Frontpage 2003 and it works perfectly. I was wondering if I could use the same code and have it linked some how to the gif images I have already created like how do I link your code with my gif. I also wanted to have it so you have to manually click the icon(gif). I had a page where all 200 files popped up at one time...not cute lol. I am very green in this field I usually fix workstations and some server 2003 issues. Web design is a new hobby...lol but I am loving it.


Quote:
Originally Posted by MadCowDzz
From what I understand of your question, there's two common options. Either a specific file download page, or javascript.



You could always create one of those traditional download pages, something like what Download.com uses... the download starts automatically when the page loads, as well as a link that reads "If the download doesn't start, click here"... Download.com actually uses an <IFRAME> to popup the dialog...

<iframe height="0" width="0" src="http://localhost/some.file"></iframe>



You could also do a javascript onload (or even onclick) function, but not all users have javascript enabled...

<body onload="javascript:window.location.href='http://localhost/some.file';">

[*edit* for some reason it looks like i'm getting a space in the word javascript from my example above... make sure you don't print that]

One problem you may encounter is that if a user's browser is setup to display the TIFF mime type (image/tiff) then the user will see the actual image, as opposed to seeing the download prompt.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignWeb Development > Script » Download file via hyperlink


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT