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

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

Who is Participating?
cwkhangConnect With a Mentor Commented:
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: 
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, 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:

allows you to access files on machine 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!

ethar1Author Commented:
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.
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

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.
ethar1Author Commented:
It's pointing to server location : http://localhost/web/Prince/Sound/p25.mp3

it's download very good but can't open it.
If you can use ASP then this is an excellent solution:
Download a file instead of opening it. IE only and assuming you have ASP capabilities:
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');


Some PHP script to force download if interested..... it will force download instead of opening file.

on your download link have something like this :


//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). "");
           echo "File does not exist";
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.