PHP 副本显示文件不存在
我使用以下代码;
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,但复制函数返回;
警告:复制('./files/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css')[function.copy]:无法打开流:没有这样的文件或目录
'./files/c7a628cba22e28eb17b5f5c6ae2a266a/0003 .css'=> './224efcdebda48350056af291f64a9311/files/8b571e7fbf9bacf4473024b11f78bc0dfiles/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css'
如果有人知道为什么,我们将不胜感激。
im using the following code;
if( ! file_exists( $path ) ) { die( "'" . $path . "' not vaild path"); }
copy( $path, ltrim($create_folder . ltrim($path, "./"), ".") );
echo "'" . $path. "' => '" . $create_folder . ltrim($path, "./") . "'<br />";
The first if statement returns true yet the copy function returns;
Warning: copy('./files/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css') [function.copy]: failed to open stream: No such file or directory
'./files/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css' => './224efcdebda48350056af291f64a9311/files/8b571e7fbf9bacf4473024b11f78bc0dfiles/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css'
If anyone knows why it would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会注意到后半部分缺少斜杠。例如,路径元素之一是“8b571e7fbf9bacf4473024b11f78bc0dfiles”而不是“8b571e7fbf9bacf4473024b11f78bc0d/files”。尝试 $create_folder 。 '/' 。 ltrim($path, "./")
但真正的答案是“你的文件实际上不存在。不,真的,PHP 是正确的”。它只是在谈论不存在的目的地;来源很好。
You might notice that your second half is missing a slash. As in, one of your path elements is "8b571e7fbf9bacf4473024b11f78bc0dfiles" instead of "8b571e7fbf9bacf4473024b11f78bc0d/files". Try
$create_folder . '/' . ltrim($path, "./")
But the real answer is "your file actually does not exist. No, really, PHP is correct". It's just talking about the destination not existing; the source is fine.