【问题标题】:PHP - open text file from another DrivePHP - 从另一个驱动器打开文本文件
【发布时间】:2015-10-30 13:13:30
【问题描述】:

我正在尝试通过 PHP 打开文本文件。当我在项目文件夹htdocs 中有文本文件时,以下代码工作正常。

<?php
   $myfile = fopen("Updates/updates.txt", "r") or die("Unable to open file!");
   echo fread($myfile,filesize("HRupdates/updates.txt"));
   fclose($myfile);
?>

现在我想从驱动器D 的另一个驱动器打开文件。

我试过这样D:/Updates/updates.txt 它不工作。还有其他方法吗?

【问题讨论】:

标签: php file fopen


【解决方案1】:

是的,它有一个方法:)。小心在文件路径中使用正斜杠。

<?php

$file=fopen('G:\\webdic.txt', "r") or die('Unable to open file');

echo fread($file,filesize('G:\\webdic.txt'));

fclose($file);
?>

这里我在我的电脑上使用 G 盘。它正在工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-23
    • 1970-01-01
    • 1970-01-01
    • 2020-01-04
    相关资源
    最近更新 更多