douxiajia6720 2017-04-18 04:27
浏览 92
已采纳

如何下载内部资源或文件盯着文件:////在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 2017-04-18 09: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.)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部