开发者

PHP copy says file does not exist when it does

开发者 https://www.devze.com 2023-01-06 18:47 出处:网络
im using the following code; if( ! file_exists( $path ) ) { die( \"\'\" . $path . \"\' not vaild path\"); }

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 direc开发者_运维技巧tory

'./files/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css' => './224efcdebda48350056af291f64a9311/files/8b571e7fbf9bacf4473024b11f78bc0dfiles/c7a628cba22e28eb17b5f5c6ae2a266a/0003.css'

If anyone knows why it would be much appreciated.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号