PHP Read or Copy File from a Network Drive (Window)

二次信任 提交于 2019-12-11 13:54:29

问题


I have a window drive mounted as

\\192.168.0.168\

It is mounted as Z drive

There this file in folder DOC,MYFOLDER,FILE1.PDF that I wanna readfile() or copy out through php (I will use it to copy other file also)

However I also tried stuffs like

$file_path = "\\192.168.0.168\DOC\MYFOLDER\FILE1.pdf";
$filesize = ($file_path); 

echo "FILE SIZE IS $filesize";

it return no value, just FILE SIZE IS

How do I access my Z drive or the 192.168.0.168\DOC\MYFOLDER\FILE1.pdf as I wanna share this Network drive file to my IIS Web Server so user can download the PDF through my web server.

Thanks!


回答1:


The backslash \ is the escape character, it needs to be escaped:

$file_path = "\\\\192.168.0.168\\DOC\\MYFOLDER\\FILE1.pdf";

Please note that PHP does not support Windows network authentication. You may be able to hack your way through, but I would rather mount the network location as a network drive.



来源:https://stackoverflow.com/questions/37020583/php-read-or-copy-file-from-a-network-drive-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!