Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to download a file

Status
Not open for further replies.

robertao

Programmer
Mar 25, 2001
1
US
Hello!

I disabled the right button on my html pages but now I want to give some .wma files for downloading. The trouble is that if I make a link to the file it will open a windows media player window - and I want to prompt for download. The files that I want to give for people download are also used on streaming audio'on my website, so I can't change their extensions or zip them. I have too many files and my server is a free one, so I'm trying not to upload everything again.

I wanted to disable the right button blocking script on this specific link or a script that I could add to a link and then when the people click it would prompt to download (or save as...), even if the file can be read by the browser (AND without having to enable the right button on entire page). I saw some sites that prompt to download a file when you enter (usually .exe) and I think this should also solve my problem. Does anyone know anything? Suggestions are welcome!
 
Why did you disable right-click? Surely allowing right-click is the easiest solution?

Greg.
 
Post the code you're using to disable the right button so I can see it.

Javascript won't force a prompt to save a file unless the content type is unrecognized or an executable program type. The only way to force a prompt to save a file is to have the client request the server with a submit button that sends the file name in a form element, then a cgi program like ASP would locate the file and write a binary file back to the browser with the content type changed in such a way that the browser won't recognize it and will force a file save prompt. If you want to see it in living color, xdrive.com has this technology. Unfortunately, since the technology resides in the CGI code, it's not available for you to see. They offer a free service so you can test it out. Post an Excel file to your virtual drive then download it. You'll notice they are using a form button to submit information to a cgi which is returned. Any other website or link to an Excel file opens in my browser. x-drive's links to Excel files placed into your virtual drive will prompt for save when you click the download button. They use a javascript function that forces you to select the file first then click the download button.

ToddWW

 
What if you link to a new page (without right click disabled) and have the download file there?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top