[英]how do I download a internal resource or a file staring file://// using wget in php?
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. 我需要下载file://///3.24.116.965/dsaspdata/Dev/hotdocs/docs/12rsocz2q4.docx
,如果将其粘贴到浏览器中,它将打开一个Word文档。 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");
我使用这样的PHP脚本将其自动化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. 显然,这是行不通的,因为无法识别file://///
。
In which format do I have to put it in shell_exec
? 我必须以哪种格式将其放入shell_exec
? ` `
wget
is a web client, it's really meant for HTTP requests. wget
是一个Web客户端,实际上是用于HTTP请求的。 But this isn't an HTTP location, it's a file system location: 但这不是HTTP位置,而是文件系统位置:
//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.) (它可能是网络安装的文件系统,但与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.) (我有点对第一个参数的确切文件位置格式的猜测,我有点生锈的就可以了。希望这个作品原样,但它可能需要一些调整。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.