douxiajia6720
2017-04-18 12:27 阅读 82
已采纳

如何下载内部资源或文件盯着文件:////在PHP中使用wget?

I need to download file://///3.24.116.965/dsaspdata/Dev/hotdocs/docs/12rsocz2q4.docx and if I paste it in browser it will open up a word document. I am automating it with PHP script like this - shell_exec("wget file://///3.24.116.965/dsaspdata/Dev/hotdocs/docs/12rsocz2q4.docx -O /tmp/batch_test/final_remu.docx");

Obviously this doesn't work because file:///// is not a recognized.

In which format do I have to put it in shell_exec? `

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    douzhenggui8171 douzhenggui8171 2017-04-18 17:23

    wget is a web client, it's really meant for HTTP requests. But this isn't an HTTP location, it's a file system location:

    //3.24.116.965/dsaspdata/Dev/hotdocs/docs/12rsocz2q4.docx
    

    (It may be a network-mounted file system, but that makes little different to PHP.)

    Instead of trying to "download" the file, just treat it like a file system operation and copy the file instead. Something like:

    copy("//3.24.116.965/dsaspdata/Dev/hotdocs/docs/12rsocz2q4.docx", "/tmp/batch_test/final_remu.docx")
    

    (I'm somewhat guessing on the exact file location format of that first argument, I'm a little rusty on it. Hopefully this works as-is, but it may need a little tweaking.)

    点赞 评论 复制链接分享

相关推荐