2013-10-11 42 views
0

我有一個下載botton..onclick的下載按鈕下載應該發生在後端,我應該繼續做其他任務..download不應該打破,當我點擊其他按鈕..是有一個PHP的方式來處理這個..如果有什麼方法可以用來 我試圖與捲曲功能但當下載按鈕被點擊下載應該發生在後端

<? 
$ch = curl_init(); 

curl_setopt($ch, CURLOPT_URL, 'http://localhost:8888/test/download_ipad.php'); 
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true); 
curl_setopt($ch, CURLOPT_TIMEOUT, 1); 

curl_exec($ch); 
curl_close($ch); 
?> 

,而不是下載它打印文件的整個

+1

應該在哪裏下載到? – putvande

+0

正常的下載當你點擊下載它必須下載爲xls文件 – namratha

回答

0

創建一個新的php文件並在按鈕href標籤中提供鏈接。

在PHP文件,你需要設置頁眉爲PDF和文件路徑,例如:

<?php 
    $filename = "filepath"; 
//header for the file type 
header('Content-type: audio/mp3'); 
header('Content-Disposition: attachment; filename="'.$filename.'"'); 
header("Content-Length: " . filesize($filename)); 
readfile($filename); 

>