I have script-1 on server A, where user ask for a file.
I have script-2 on server B (the file repository) where I check that user can access it and return the correct file (I m using Smart File Download http://www.zubrag.com/scripts/download.php).
I ve Trial cURL and file_get_contents, I ve以各种方式改变了内容标题,但In t仍然能够下载档案。
这是我的要求:
$request = "http://mysite.com/download.php?f=test.pdf";
and it works fine. What should I call in script-1 to force the file be downloaded?
www.un.org/Depts/DGACM/index_spanish.htm 我的一些著作:
这项工作,但我不知道如何处理未经许可或中断的下载。
header( Content-type: application/pdf );
$handle = fopen($request, "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
echo $buffer;
}
fclose($handle);
}
这在浏览器(我认为它是一个头重问题)中直接打印了《pdf法》(而不是文本):
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $request);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
这产生了一个白页。
file_get_contents($request);