开发者

Forcing a download using PHP

开发者 https://www.devze.com 2022-12-16 04:31 出处:网络
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

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消