我正在尝试将我的文件从一个目录复制到另一个目录(文件不存在的目标)
据我了解,如果要重命名并且文件已存在于目标目录中,则复制功能才有效;如果目标目录中不存在该文件怎么办?
我的尝试:
public function addSlidesToPath()
{
$myAddr=$this->input->post('addr');
$src=realpath(BASEPATH.'../uploaded_images').'/'.$myAddr[0];
$dest="C:\\Slides";
return copy( $src , $dest. basename($src ));
}
如果您需要更多说明,请告诉我;如果目标中存在同名文件,我的代码可以正常工作,但如果没有同名文件,则它不起作用!
ADDED Here you can see my different attempts:
1)for **copy** without basename the error is "The second argument of copy() function cannot be a directory"
2)for **copy** with basename the error is "The second argument of copy() function cannot be a directory" as well
3)for **move_uploaded_file** with basename there is no error but the result is false!
4)for **move_uploaded_file** without basename there is no error but the result is false!
谢谢