PHP:是否绕过外部下载的file_get_contents()?

时间:2016-07-05 14:13:19

标签: php file-get-contents downloading mirroring

以下问题: 我的服务器上有一个大文件(~2GB)。 登录到我站点的用户可以从我的服务器下载此文件。

不幸的是我的服务器并不那么强大。当许多用户同时下载此文件时,他们都将具有非常差的dl速度。

所以我将文件上传到谷歌驱动器并生成了直接下载链接: http://googledrive.com/host/[FILE_ID]

我的代码:

<?php
  $remoteFile = 'http://googledrive.com/host/[FILE_ID]';
  $filename = basename($remoteFile);
  header("Content-Type: application/octet-stream");
  header("Content-Disposition: attachment; filename=\"$filename\"");
  echo file_get_contents($remoteFile); 
?>

我的问题:file_get_contents()是否真的绕过了dl,或者这个文件是通过我的服务器进行的?如果是这样,那就没有意义了:[]

1 个答案:

答案 0 :(得分:0)

每次下载后都会生成一个唯一的Google驱动器共享链接,以便只有经过身份验证的用户才能下载,并且链接可能不会多次使用。

相关问题