I need to make the user able to download a file from my webpage on clicking a link on my website
I tried <a href='./image.ext'>Download file</a>
By it just opened a new window and i need to right click and select "save page as"
What I am expected is ,after clicking my link user must see a dialogue box "save as" as usual...How to do it..Is there any way in HTML to force download by showing such a dialogue
Note:Since stackoverflow is not allowing anchor tag,i just typed it as a.Plea开发者_如何学运维se do not treat it as a mistake
If you're using an Apache web server, you can use the .htaccess
file to force file download for certain file extensions. Add this line to your .htaccess
to cause the "Save As" dialog to appear when the link is clicked:
AddType application/octet-stream .ext
If you wanted the same behaviour for a PDF or AVI, the following lines would do it:
AddType application/octet-stream .pdf
AddType application/octet-stream .avi
You can use php to readfile() the file to the user.
this tutorial would be helpful for you : http://webdesign.about.com/od/php/ht/force_download.htm
I know it is lame, but I found a solution here
精彩评论