dragon7713 2017-02-14 12:51
浏览 209
已采纳

警告:filectime():stat失败的路径

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!

  • 写回答

1条回答 默认 最新

  • doutang3760 2017-02-14 13:25
    关注

    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");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了