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

警告: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 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿