drt41563 2012-05-08 06:58
浏览 106
已采纳

使用php下载文件失败

The file that I have is:

$file_path='CSVs/data'.time().'TaskID_'.$this->task_id.'.csv';

Then I attach it to this function.

$save_to="Y:\SEO\Avi\BackLinks";
$this->download_remote_file(
    "http://212.13.98.158/backlinks/".$file_path, $save_to);

function download_remote_file($file_url, $save_to)
{
    $content = file_get_contents($file_url);
    file_put_contents($save_to, $content);
}

That file should retrieve the files contents and copy it to the directory.

The errors that I get are to do with 404 and that the folder doesnt exist. But I do know for a fact, that the folder exists..and I am quite sure that the links is the right link that points to the resource

UPDATE: mADE THE CHANGES..this simple example..throws me 403 forbidden. saying that the file or directory doesnt exist.

    $save_to="Y:\SEO\Avi\BackLinks\data1335692353TaskID_122.csv";
      $this->download_remote_file("http://212.199.198.158/backlinks/CSVs/data1335692353TaskID_122.csv", $save_to);
  • 写回答

2条回答 默认 最新

  • dongwei1921 2012-05-08 07:31
    关注

    Look at your file_path: 212.13.98.15/backlinks/data1335692201TaskID_122.csv. It is not the path in the post: $file_path='CSVs/data'.time().'TaskID_'.$this->task_id.'.csv'; Remove the CSVs/

    And what about the filename and its extention? You need them to tell under which name to write a file.

    Your $save_to has to be a kind of $save_to="Y:\SEO\Avi\BackLinks\abc.cvs";

    UPDATE - Try each operation separately. First, echo the get_file_contents, or a few lines of it. Then try to put a simple "hello.txt" or whatever on your savepath.

    If then you'll recieve same error - check the permissions.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效