0

SOLVED: Look at this comment!

I have this php page echoing some xml data, which the user should save. I want the page to automatically open the "Save as" window, since the page downloading the data is called "download.php" this won't start a "Save as" by it self. I read a lot of other threads here on stackoverflow by people asking the same question. None of those solves my problem. So yes, I am creating a duplicate by purpose.

This is my code:

$file.='<bpage>';
$file.='<title>'.$_POST["title"].'</title>';
$file.='<desc>'.$_POST["desc"].'</desc>';
$file.='<cont>'.$_POST["cont"].'</cont>';
$file.='<img>'.$_POST["img"].'</img>';
$file.='<tdata>'.$_POST["tdata"].'</tdata>';
$file.='<link>'.$_POST["link"].'</link>';
$file.='<writer>'.$_POST["writer"].'</writer>';
$file.='<date>'.$_POST["date"].'</date>';
$file.='</bpage>';

header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$_POST["title"].'.bpage');
echo $file;

I am not having any "Save as" dialog, simply the usual page, as if it ignored all my headers. I am using Chrome and the latest version of PHP.

--
Regards Locercus

Edit: I am using One.com for hosting. Could they possibly be blocking the header function?

4

1 回答 1

0

好像您的 chrome 设置为自动下载文件。在这种情况下,您将看不到任何保存对话框,但文件将下载到您的默认 chrome 下载位置。

要查看保存对话框,请执行以下操作:

  • 转到 Chrome 扳手菜单 > 设置 > 高级设置 > 下载并选中显示的框Ask where to save each file before downloading
于 2012-08-21T18:20:12.387 回答