Solved

How force link to save target as instead of open it?

Posted on 2004-10-13
8
834 Views
Last Modified: 2008-01-09
Dear all,
How force link to save target as instead of open it?
Thanks.


0
Comment
Question by:ethar1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 21

Expert Comment

by:briancassin
ID: 12295399
what exactly are you trying to accomplish ???

If you are talking about making so that the box comes up when you left click on the link to download a file then you would put it up on a server that has FTP capability and make it an ftp link.

Files can be referenced via FTP using the URL convention. The general form is:
ftp://internet.address.edu/file/path/file.txt 
This form makes an anonymous FTP request for the indicated file from the indicated machine.

If you specify a directory instead of a file (by requesting a URL such as ftp://internet.address.edu/file/path/, most browsers will give you a list of the directory contents and allow you to select files, or other directories.

NOTE -- If a URL points to a directory it *must* end with the slash character. This tells the URL that the desired target is a directory (i.e. the directory path/) and not a file (i.e. the file path).

You can access non-anonymous ftp resources by specifying, within the URL, both the username and password of the account you wish to access. ( NOTE -- This is not secure -- see the following warning). For example:

ftp://joe_bozo:bl123@internet.address.edu/path/file.gz

allows you to access files on machine internet.address.edu belonging to user joe_bozo (password bl123). Note that you can omit the password if you wish -- most browser's will then attempt the connection, but will prompt the user to type a password. Indeed, it is best to omit the password -- otherwise everybody who accessss this document will be able to read the HTML and know joe_bozo's password!

0
 

Author Comment

by:ethar1
ID: 12295426
Actually, I have mp3 link, when I click the link it's open in realplayer but give an error:

A general Error has occurred...
file://C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files\Content.IE5\KTSH2Z85\P16[2].mp3


don't know how to fix that.
0
 
LVL 21

Expert Comment

by:briancassin
ID: 12295473
the link is pointing at your local machine's hard drive

you would have to have that file uploaded onto a file server or you would have to have your machine setup as a file server. Otherwise it will not work.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ethar1
ID: 12295657
no,
It's pointing to server location : http://localhost/web/Prince/Sound/p25.mp3


it's download very good but can't open it.
0
 
LVL 6

Accepted Solution

by:
cwkhang earned 250 total points
ID: 12295695
0
 
LVL 3

Expert Comment

by:WhisperUK
ID: 12297189
If you can use ASP then this is an excellent solution:
http://www.xefteri.com/articles/may082002/default.aspx
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12297844
Download a file instead of opening it. IE only and assuming you have ASP capabilities:
<%@Language="JScript"%>
<%
var myFSO = new ActiveXObject("Scripting.FileSystemObject")
var objFile = myFSO.openTextFile(Server.MapPath("/path/somefile.ppt"));
var str = new String(objFile.readAll());
Response.ContentType = 'application/unknown';
Response.addHeader('content-disposition', 'attachment;filename=somefile.ppt');
Response.Write(str);
%>

Cd&

0
 
LVL 12

Expert Comment

by:minichicken
ID: 12298704
Some PHP script to force download if interested..... it will force download instead of opening file.

on your download link have something like this : http://www.your_domain.com/download.php?file=http://localhost/web/Prince/Sound/p25.mp3

<?

//this is download.php

      $file= $_GET['file'];

      if (file_exists($file))
      {
         header("Content-type: application/force-download");
         header("Content-Transfer-Encoding: Binary");
         header("Content-length: ".filesize($file));
         header("Content-disposition: attachment; filename=".basename($file). "");
         readfile("$file");
      }
      else
      {
           echo "File does not exist";
      }
?>
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question