我正在創建一個xml文件。當用戶生成這個文件時,我希望它用生成的內容打開一個下載文件對話框。沒有實際的文件,因爲它只是通過php生成的。任何想法如何做到這一點?php強制下載xml
3
A
回答
5
13
這是我工作的。在readfile('newfile.xml');
請確保正確給出文件的路徑。這個PHP頁面從定位標記它說的HTML頁面叫做 - 下載:
<?php
header('Content-disposition: attachment; filename="newfile.xml"');
header('Content-type: "text/xml"; charset="utf8"');
readfile('newfile.xml');
?>
來源:How do I force the browser to download a file to disk instead of playing or displaying it?
0
header('Content-disposition: attachment; filename=advertise.xml');
header ("Content-Type:text/xml");
//output the XML data
echo $xml;
// if you want to directly download then set expires time
header("Expires: 0");
+0
,請爲用戶理解添加一些說明 – Cris 2014-02-05 10:04:52
相關問題
- 1. PHP強制下載
- 2. 強制在php下載
- 3. php:強制下載到hd?
- 4. PHP強制文件下載
- 5. 如何強制下載PHP?
- 6. PHP-Ajax強制下載
- 7. Php readfile - 強制下載
- 8. 如何在python中強制下載xml?
- 9. 強制下載
- 10. 編寫一個xml文件並強制用php下載
- 11. 強制用戶下載文件在PHP
- 12. 無法強制下載 - PHP curl
- 13. 強制php下載ZIP中的文件
- 14. PHP強制下載遠程文件
- 15. 用PHP強制下載文件
- 16. 使用PHP強制下載PDF
- 17. 強制用戶下載.txt(php,file.txt)
- 18. PHP強制下載轉到網頁
- 19. 強制從服務器PHP下載
- 20. PHP:強制下載後顯示內容?
- 21. php重定向+強制下載
- 22. php中的強制文件下載
- 23. php強制下載.app文件?
- 24. 無法用PHP強制下載文件
- 25. PHP:強制PDF文件下載
- 26. PHP CSV創建並強制下載
- 27. 強制下載PHP中的文件
- 28. PHP:強制下載不起作用
- 29. PHP讀取文件()不強制下載
- 30. 強制在php下載文件?
你明明didnt閱讀我的文章。沒有實際的文件可讀。它只是發送到頁面,我不想創建一個文件只是能夠下載它生成的文件。 – ngreenwood6 2010-04-23 06:00:07
@ngreen你顯然沒有閱讀鏈接的文章。設置所述頭部並回顯xml數據。 – Amarghosh 2010-04-23 06:06:37
哦,不錯,我以爲你真的不得不分配它的文件...謝謝你的信息 – ngreenwood6 2010-04-23 06:14:40