0
我發現這個腳本的作用像一個魅力,但我的下載文件現在有名稱中的網址。我該如何刪除它?如何從下載文件中刪除網址
The html:
<a class="download_link" href="catalogue/CP-Greengo-Filtertips-30027.jpg"><img src="CP-Greengo-Filtertips-30027.jpg" width=100 alt=image></a>
The jQuery:
$('a.download_link').on('click', function (event) {
event.preventDefault(); //prevent the normal click action from occuring
window.location = 'php/filedownload.php?file=' + encodeURIComponent(this.href);});
The php:
$file = $_GET['file'];
header('Content-Description: File Transfer');
header("Content-type: application/octet-stream");//notice this content-type, it will force a download since browsers think that's what they should do with .exe files
header("Content-disposition: attachment; filename= ".$file."");
readfile($file);
感謝所有
Wauw,那很快!絕對的輝煌。非常感謝格雷格:) – Jimmy 2012-08-07 22:41:52
沒問題。確保接受答案,如果它解決了你的問題。 – gcochard 2012-08-07 22:55:42
啊,好的。它有用嗎?我的第一篇文章在這裏。 – Jimmy 2012-08-07 23:41:36