[英]How can I redirect to a another page after using request download cakephp2
我想問一個問題如何在使用$this->response->download;
后重定向到另一個頁面$this->response->download;
by cakephp 2.我已經使用:
$this->response->download($new_file_name);
print($output);
$this->Flash->success(__('The file has been successfully export.'));
return $this->redirect(array('action' => 'index'));
但它運作不佳。 這是另一種方式嗎?謝謝
這是不可能的,它是瀏覽器請求工作方式的限制。 您可以在此答案中找到更多信息。
常見的事情(例如在流行的下載站點中)是相反的:首先,您轉到“之后”頁面然后開始下載。
因此,將用戶重定向到您希望他們結束的位置,然后提供下載。
試試這個,但不確定是否會奏效。
$download='no';
$this->response->download($new_file_name);
print($output);
$download='yes';
if($download=='yes')
{
return $this->redirect(array('action' => 'index'));
}
else
echo 'sorry did not downloaded';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.