【问题标题】:PHP copy says file does not exist when it doesPHP副本说文件不存在
【发布时间】:2011-03-15 03:14:59
【问题描述】:

我使用下面的代码;

if( ! file_exists( $path ) ) { die( "'" . $path . "' not vaild path"); }
copy( $path, ltrim($create_folder . ltrim($path, "./"), ".") );
echo "'" . $path. "' => '" . $create_folder . ltrim($path, "./") . "'<br />";

第一个 if 语句返回 true 但复制函数返回;

Warning: copy('./files/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css') [function.copy]: failed to open stream: No such file or directory

'./files/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css' =&gt; './224efcdebda48350056af291f64a9311/files/8b571e7fbf9bacf4473024b11f78bc0dfiles/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css'

如果有人知道为什么会非常感激。

【问题讨论】:

    标签: php file copy not-exists


    【解决方案1】:

    您可能会注意到您的后半部分缺少一个斜线。如您的路径元素之一是“8b571e7fbf9bacf4473024b11f78bc0dfiles”而不是“8b571e7fbf9bacf4473024b11f78bc0d/files”。试试$create_folder . '/' . ltrim($path, "./")

    但真正的答案是“您的文件实际上不存在。不,真的,PHP 是正确的”。它只是在谈论不存在的目的地;来源很好。

    【讨论】:

    • It's just talking about the destination not existing; the source is fine.我是个假人
    猜你喜欢
    • 2018-07-15
    • 2015-07-16
    • 1970-01-01
    • 2017-03-01
    • 1970-01-01
    • 2011-01-20
    • 2015-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多