php - How to get a file from remote server and dispose to user as a download? -
sorry if did not title right.
i have in server redirect.php script receives url passed client user, fetches content using file_get_contents()
function , them shows user echo()
function.
the problem when user points directly pdf or jpg file in url , them script shows file contents binary code.
when set code recognize when requested url points directly downloadable file,
what should function or header echo user browser ask him download file insted of showing it?
do have first put file inside server or can directly command file_get_contents()
? if can without writing server, better approuch.
i can't point directly server because sites blocked employee , third party company service thinks stakexchenge sites malicious , not constructive , tegged online communities facebook.
try this:
$sourcefile = "http://www.myremotewebsite.com/myfile.jpg"; $destfile = "myfile.jpg"; copy($sourcefile, $destfile);
Comments
Post a Comment