使用PHP下载动态生成的文件

时间:2011-11-09 17:50:42

标签: php file download

这听起来真的很不错#34; nooby"但我需要找到一种方法让PHP将XLS文件下载到服务器文件夹。此文件不存储在另一个服务器中,它是使用另一个PHP脚本动态生成的。 这是我浏览网页时得到的,但它不起作用:

  <?php
  $url = "http://localhost/ProyectoAdmin/admin/export_to_excel.php?id=1&searchtype_id=2";
  $local_file_path = './xls_tmp/Report.xls'; 
  $xlsFile = file_get_contents($url);
  file_put_contents($file_path,$xlsFile);
  ?>

我真的很感激任何提示。

1 个答案:

答案 0 :(得分:2)

你错过了第二行的结束语。

应该是:$local_file_path = './xls_tmp/Report.xls';

相关问题