【问题标题】:PHP Copy file to my website from remote sitePHP 将文件从远程站点复制到我的网站
【发布时间】:2014-02-02 20:24:30
【问题描述】:
 $link = "http://vcdn8.yobt.tv/content/a8/68/e6/a868e6dc4688ecfc0c26de00ed08db7f871427/vid/1_1024x576.mp4";
copy($link, '../video/video12465123.mp4');

我正在尝试复制此视频,但总是停在 1 mb - 2 mb 之间,并且显示

500 内部服务器错误 服务器遇到内部错误或配置错误,无法完成您的请求。

请联系服务器管理员,告知错误发生的时间以及您所做的任何可能导致错误的事情。

服务器错误日志中可能会提供有关此错误的更多信息。

错误日志: [Mon Feb 03 06:36:38 2014] [warn] [client 217.131.165.102] mod_fcgid:读取数据超时 45 秒 [Mon Feb 03 06:36:38 2014] [error] [client 217.131.165.102] 脚本头过早结束:videoekle.php

【问题讨论】:

  • 检查您的 PHP 日志以获取实际错误,然后报告

标签: php linux


【解决方案1】:

这是一个 apache 超时错误。如果您从命令行(而不是通过 apache)运行 PHP 脚本,则不应出现此超时错误。如果需要通过 apache 运行脚本,可以在 /etc/httpd/conf.d/fcgid.conf 中增加 FcgidIOTimeout 设置,然后重启 apache,就可以解决问题了。

【讨论】:

    【解决方案2】:

    尝试使用curl,强制超时

    set_time_limit(400);// to infinity for example
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://vcdn8.yobt.tv/content/a8/68/e6/a868e6dc4688ecfc0c26de00ed08db7f871427/vid/1_1024x576.mp4");
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 400); //timeout in seconds
    $response = curl_exec($ch);
    curl_close($ch);
    

    然后将其保存到文件中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多