2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > wordpres报错sfile_exists() [function.file-exists]: File name is longer than the maximum allowed

wordpres报错sfile_exists() [function.file-exists]: File name is longer than the maximum allowed

时间:2022-04-28 20:22:20

相关推荐

wordpres报错sfile_exists() [function.file-exists]: File name is longer than the maximum allowed

在最近的一次后台升级 wordpress4.4 中文版之后,点击博客中标题比较长的文章,页面上就爆发了这个错误。这个错误的意思是“文件名称超过了这个平台所允许的最大长度限制”。那就让人有点奇怪了,为什么以前没有出现这个错误呢?

我部署博客用的是 windows server 的平台,PHP+Apache+Mysql,理论上来讲不应该出现这个字符限制的。一开始我怀疑是不是PHP的配置出了问题,因为 file_exists() 函数毕竟是在php的环境下运行,后来也觉得不太对,以前的配置完全可以正常运行,毛线问题没有。难道是 file_exists() 的算法是在 wordpress4.4 的个别PHP文件新增的?

如果是这样的话,php.ini 根本没有类似限制字符长度的配置,有的只是一些模块读写、目录权限及文件大小之类的配置。

后来发现了两篇网友的文章,一个叫 Jeffrey Cameron 的网友问了如下的问题:

Why does the 260 character path length limit exist in Windows?

I have come up against this problem a few times at inopportune moments:

trying to work on open source Java projects with deep pathsStoring deep Fitnesse wiki trees in source controlAn error trying to use Bazaar to import my source control tree

Why does this limit exist?

Why hasn’t it been removed yet?

How do you cope with the path limit? … and no, switching to linux or Mac OS X is not a valid answer to this question ;)

意思就是他在编程的时候遇到260个字符长度的限制,是基于 windows 平台的,但是在 Linux 和 MacOS 平台上这个问题是不存在的。所以他在声讨相关的开发人员,为何这个遗留问题仍然没有解决?也就是说在微软的 windows 平台上 file_exists() 的260个字符长度限制在确实存在的。

还有一个叫 Waqleh 的网友直接遇到了这个问题:

How to fix PHP Warning: file_exists(): File name is longer than the maximum allowed path length on this platform (260)?

> PHP Warning: file_exists(): File name is longer than the maximum

> allowed path length on this platform (260):

> C:\Inetpub\vhosts\\\qa\xxx\assets\js\plugin\tiny_mce\plugins\ibrowser\scripts\phpThumb\cache\5\56\56b\56b7\__src56b72e3bbea26ba9aec8b0449cabc81d_par0b9e73569dbbfe81d5e1ff2a11d92887_dat1389704510.jpeg

> in

> C:\Inetpub\vhosts\\\qa\xxx\assets\js\plugin\tiny_mce\plugins\ibrowser\scripts\phpThumb\phpThumb.php

> on line 588

这个小伙子在部署自己的网站的时候遇到了类似问题,可以发现他的网站目录也是挺长的。file_exists() 在百科解释中是用来检查文件或者目录是否存在,传入的参数是fileName,但我觉得这个参数绝不仅仅是个文件名,而应该是个文件路径 filePath。只有结合目录才能判断文件存在的意义,否则一个单纯的文件名字有多大意义?中国有多少个叫“李飞”的名字的人,有意义吗?但如果说是郑州市东风南路绿地之窗云峰座15楼1503室的李飞,这个人的形象就清晰起来,那就有意义了(贫嘴一下下)。

最佳答案(Best Answer)

下面是一个俄罗斯网友sємsєм 的回答:

Simply apply the advice of the message. Rearrange your files’ structure.

意思是“仅仅提供一个消息性建议,整理下你的文件目录结构。“。这是有多简洁?Winodws 平台下确实存在这个问题,要么你不用 file_exists() 方法进行php算法判断,要么你换个服务器平台。最简单的就是把项目的文件目录优化了,不要放在多层文件夹下,超过了260个字符的限制。这应该是最简单的处理方案了。

所以……我把项目目录转移到了一个盘的根目录下,项目目录就几层,哪里还会有超限的问题。不过这个缺陷是在 php 中不应该存在的,望php的相关开发人员修正这个平台性问题。同时,wordpress 开发人员发布新版本时,应该提前进行内部测试以发现这种漏洞。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。