php 文件错误。愚蠢的小问题

发布于 2024-08-29 09:21:58 字数 322 浏览 2 评论 0原文

使用 xampp 在桌面上工作正常,但当我将其上传到我的网络主机时,却无法正常工作。文件 x.csv 位于同一目录中,

$csv_file = "x.csv";

$handle = fopen(($csv_file), "r");

我得到的错误是-

fopen(x.csv): failed to open stream: No such file or directory in /var/www/html/x/admin/import_one.php on line 12

我哪里出错了?

works fine on the desktop with xampp but when i upload it to my webhost it doesnt. The file x.csv is in the same dir

$csv_file = "x.csv";

$handle = fopen(($csv_file), "r");

the error i get is-

fopen(x.csv): failed to open stream: No such file or directory in /var/www/html/x/admin/import_one.php on line 12

Where am I going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半寸时光 2024-09-05 09:21:58

检查您是否具有 x.csv 的读取权限
也尝试一下

$handle = fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . $csv_file, 'r'); 

(maybe your cwd isn't in the same directory)

check that you have reading permissions for x.csv
also try

$handle = fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . $csv_file, 'r'); 

(maybe your cwd isn't in the same directory)

靑春怀旧 2024-09-05 09:21:58

Linux 区分大小写,Windows 不区分大小写。

确保您的文件名为 x.csv,而不是 X.csvx.CSV

Linux is case-sensitive, Windows isn't.

Make sure that your file is called x.csv and not X.csv or x.CSV.

凡尘雨 2024-09-05 09:21:58

如有疑问,请使用绝对文件路径。

$path = '/path/dir/something/';
$file = 'x.csv';

$fp = fopen($path . $file, 'r');
if ($fp)
{ 
    // do some amazing stuff here.
}

When in doubt use absolute file path.

$path = '/path/dir/something/';
$file = 'x.csv';

$fp = fopen($path . $file, 'r');
if ($fp)
{ 
    // do some amazing stuff here.
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文