简体   繁体   中英

Download a dynamically generated file using PHP

This might sound really "nooby" but I need to find a way for PHP to download an XLS file to a server folder. This file is not stored in another server, it is dynamically generated with another PHP script. This is what I got from browsing the web but it's not working:

  <?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);
  ?>

I'd really appreciate any hint.

You're missing an end quote on your second line.

It should be: $local_file_path = './xls_tmp/Report.xls';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM