php copy
snippet in php

php copy

user936


<?php
$file = 'example.txt';
$newfile = 'example.txt.bak';

if (!copy($file, $newfile)) {
    echo "failed to copy $file...\n";
}
?>

php copy overwrite

user1282

<?php 
  
// Copying gfg.txt to geeksforgeeks.txt 
$srcfile = '/user01/Desktop/admin/gfg.txt'; 
$destfile = 'user01/Desktop/admin/geeksforgeeks.txt'; 
  
if (!copy($srcfile, $destfilefile)) { 
    echo "File cannot be copied! \n"; 
} 
else { 
    echo "File has been copied!"; 
} 
  
?> 

php copy

user4439

$file = 'http://3.bp.blogspot.com/-AGI4aY2SFaE/Tg8yoG3ijTI/AAAAAAAAA5k/nJB-mDhc8Ds/s400/rizal001.jpg';
$newfile = '/img/submitted/yoyo.jpg';

if ( copy($file, $newfile) ) {
    echo "Copy success!";
}else{
echo "Copy failed.";
}