0

我在 E: 驱动器中的 PC 中有一个文本文件我在 php 本地主机中读取了这个文件,它工作正常,但是当想要从实时站点读取时不起作用。在本地主机上这是我的代码

$myFile = "E:\\textfile.txt";
$fh = fopen($myFile, 'r');

if ($fh) {
$array = explode("\n", fread($fh, filesize($myFile)));
}

fclose($fh);

foreach($array as $v){

$data=explode("*",$v);

$msg=$data[0];

$num=$data[1];

}

但是相同的代码在 cpanel 的实时站点上不起作用

4

1 回答 1

3

The answer is simple : you can't... server-side code runs on server, so you can't access client. The fact it works on your local environment is only because your server is then the same machine as you client. You should either ask the user to upload the file to the server, then process it, or store the file on your server if it isn't supposed to be provided by the user...

于 2013-09-26T16:50:40.770 回答