警告:filectime():路径统计失败 [英] Warning: filectime(): stat failed for path

查看:32
本文介绍了警告:filectime():路径统计失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取使用 PHP 修改或创建文件的日期.为此,我使用 filectime 函数,但它总是给我以下错误:

<块引用>

警告:filectime():路径统计失败

其中路径是我存储文件的路径.

路线与此类似:

http://MYIP/documents/animals 文档1.pdfhttp://MYIP/documents/animals 文档2.pdf...

并且我必须替换 url 来编码文件的空格:

$path= str_replace(' ', '%20', $path);

如果我这样做,我可以使用一个链接在我的浏览器上打开这个文件,但是如果我尝试在 filectime 函数上使用相同的路径,它会显示我之前放置的警告.

我错过了什么吗?

提前致谢!

解决方案

filectime 函数需要一个字符串路径作为参数.它只是对 Posix stat 系统调用使用的包装函数.

系统调用:

<块引用>

int stat(const char *pathname, struct stat *buf);

因此,它需要一个参数,就好像它在您的文件系统上一样.URL 被编码为在服务器端有一个整洁的无空格标识符以执行适当的脚本.

不要理会那个编码"!只需使用您在 UNIX shell 上使用的标准字符串路径,相对于脚本目录.

在这种情况下,只需提供 PHP 函数的正确路径即可!

filectime("文档/动物文档2.pdf");

I am trying to get the date in which a file was modified or created with PHP. To do this I am using filectime function but it is giving me always the following error:

Warning: filectime(): stat failed for path

where path is the route in which I have stored the file.

The route is something similar to this:

http://MYIP/documents/animals document 1.pdf
http://MYIP/documents/animals document 2.pdf
...

and I have to replace the url to codify the spaces of the file:

$path= str_replace(' ', '%20', $path);

If I do this I can use a link to open this file on my browser but it shows the warning that I have put before if I try to use the same path on filectime function.

Am I missing something?

Thanks in advance!

解决方案

The filectime function expects a string path as a parameter. It is just a wrapper function over the usage of Posix stat system call.

The system call:

int stat(const char *pathname, struct stat *buf);

So, it expects a parameter as though it's on your filesystem. The URL gets encoded to have a neat white-space-less identifier on the server side to execute appropriate scripts.

Don't bother with that "codification"! Just use a standard string path as you'd use on your UNIX shell, relative to the script directory.

In this case, just provide the right path to the PHP function!

filectime("documents/animals document 2.pdf");

这篇关于警告:filectime():路径统计失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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