本文實例講述了php不使用copy()函數復制文件的方法。分享給大家供大家參考。具體如下:
下面的代碼不使用php內置的copy函數,直接通過文件讀取寫入的操作方式復制文件
<?php
function copyfiles($file1,$file2){
$contentx =@file_get_contents($file1);
$openedfile = fopen($file2, "w");
// http://www.manongjc.com/article/1350.html
fwrite($openedfile, $contentx);
fclose($openedfile);
if ($contentx === FALSE) {
$status=false;
}else $status=true;
return $status;
}
?>