Home >Backend Development >PHP Tutorial >PHP rename and copy files_PHP tutorial

PHP rename and copy files_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:06:351018browse

php rename and copy files
$nname = $nowpath.$newfilename;
if (file_exists($nname) || !file_exists($oldname)) {
m($nname.' The target file already exists or the original file does not exist');
} else {
m(basename($oldname).' Rename'.basename($nname).(@rename($oldname,$nname) ? 'Success' : 'Failure'));
}
}

// Copy file
elseif ($sname && $tofile) {
if (file_exists($tofile ) || !file_exists($sname)) {
m('The target file already exists or the original file does not exist');
} else {
m(basename($tofile).' copied '. (@copy($sname,$tofile) ? basename($tofile).' Success' : 'Failure'));
}


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445025.htmlTechArticlephp Rename and copy files $nname = $nowpath.$newfilename; if (file_exists($nname) || !file_exists($oldname)) { m($nname.' The target file already exists or the original file does not exist');...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn