简体   繁体   中英

How to read file from remote server without FTP, using php?

First I want to read a file with path

$file = readfile("\\10.96.5.94\\DIR\\README.txt");

It is giving error no such file directory exists.

I have also tried fopen and file_get_contents functions.

Which I am able to access from my php server.

10.96.5.94 is just a file server, from which I want to read a file, and attach it in mail.

Is it possible to directly attach file by reading it from server?

Or I need to copy it on server and attach it?

You are trying to get read file from other server.

Whatever file you want to read, you must have to give full server path as the the file,

for example see below lines. My following line is not working proper if i haven't give a proper path. $a = file_get_contents('google.com'); - Not working proper $a = file_get_contents('google.com'); - Not working proper.

Instead write following lines to get proper results,

$a = file_get_contents('http://www.google.com'); - It works good. So try this way.

Thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM