views:

33

answers:

1

Hi, 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.

+2  A: 

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.

Borealid
`It's just talking about the destination not existing; the source is fine.` im a dummy
Phil Jackson