file_exists()返回false,但该文件确实存在 [英] file_exists() returns false, but the file DOES exist

查看:466
本文介绍了file_exists()返回false,但该文件确实存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与file_exists一个很奇怪的问题()。我使用这个功能来检查,如果确实存在在同一文件夹中2个不同的文件。我仔细检查,他们都确实存在。

I'm having a very weird issue with file_exists(). I'm using this function to check if 2 different files in the same folders do exist. I've double-checked, they BOTH do exist.

echo $relative . $url['path'] . '/' . $path['filename'] . '.jpg';
Result: ../../images/example/001-001.jpg

echo $relative . $url['path'] . '/' . $path['filename'] . '.' . $path['extension'];
Result: ../../images/example/001-001.PNG

现在让我们使用这些file_exists():

Now let's use file_exists() on these:

var_dump(file_exists($relative . $url['path'] . '/' . $path['filename'] . '.jpg'));
Result: bool(false)

var_dump(file_exists($relative . $url['path'] . '/' . $path['filename'] . '.' . $path['extension']));
Result: bool(true)

我不明白这一点 - 这两个文件确实存在。我运行Windows,所以它不是涉及到区分大小写的问题。安全模式是关闭的。

I don't get it - both of these files do exist. I'm running Windows, so it's not related to a case-sensitive issue. Safe Mode is off.

什么是可以值得一提的是,虽然在巴纽一个被通过FTP用户上传,同时是使用脚本创建的.JPG之一。但据我所知,这不应该有所作为。

What might be worth mentioning though is that the .png one is uploaded by a user via FTP, while the .jpg one is created using a script. But as far as I know, that shouldn't make a difference.

任何提示?

感谢

推荐答案

file_exists结果()的缓存,所以请尝试使用 clearstatcache( )。如果没有帮助,重新检查的名字 - 他们可能是类似的,但不一样的。

Results of the file_exists() are cached, so try using clearstatcache(). If that not helped, recheck names - they might be similar, but not same.

这篇关于file_exists()返回false,但该文件确实存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆