Forcing a download using PHP
I have PHP issue, I'm trying to force a file download using php
if users click on my link www.site.com/download.php it redirects them to download.php with the following code inside the download.php file
header('Content-Type: application/csv');
header('Content-Disposition: attachmen开发者_JAVA百科t; filename=custom_report.csv');
header('Pragma: no-cache');
echo readfile('files/csv/custom_report.csv');
readfile and fopen however is disabled on the server for security purposes.
Is there any other way I can do this
How about file_get_contents()?
If readfile and fopen aren't available, I'd expect all the file I/O fns to be disabled too.
In which case your only option is to provide a hard link to the csv file (but your service provider probably hasn't added the CSV mime mappings)
C.
From what I understand your problem is not getting the file to download but rather finding an alternative to readfile/fopen?
精彩评论