how to copy file or directory in PHP scripts code copying files directories
RegisterLogin
how to copy file or directory in PHP scripts code copying files directories
Post Description: how to copy file or directory in PHP scripts code copying files directories
Tags: how, to, copy, file, or, directory, in, PHP, scripts, code, copying, files, directories
This Post Was Posted On Feb 29, 2008 By web hosting #1336
Post Description: how to copy file or directory in PHP scripts code copying files directories
Tags: how, to, copy, file, or, directory, in, PHP, scripts, code, copying, files, directories
This Post Was Posted On Feb 29, 2008 By web hosting #1336
how to copy file or directory in PHP scripts code copying files directories by web hosting
well, you're in luck because yes it is possible.
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
hostman
#1759 1
How To Copy File
<?php
$file = 'old_file.txt';
$newfile = 'new_file.txt';
if (!copy($file, $newfile)) {
echo "failed to copy $file...n";
}
?>
$file = 'old_file.txt';
$newfile = 'new_file.txt';
if (!copy($file, $newfile)) {
echo "failed to copy $file...n";
}
?>
you can get more info at:
http://www.php.net/manual/en/function.copy.php
Mar 08, 2008 Reply Report abuse
hostman
#1758 2
How to copy Directory
to copy directory you can use this handy function:
function full_copy( $source, $target ) {
if ( is_dir( $source ) ) {
@mkdir( $target );
$d = dir( $source );
while ( FALSE !== ( $entry = $d->read() ) ) {
if ( $entry == '.' || $entry == '..' ) {
continue;
}
$Entry = $source . '/' . $entry;
if ( is_dir( $Entry ) ) {
full_copy( $Entry, $target . '/' . $entry );
continue;
}
copy( $Entry, $target . '/' . $entry );
}
$d->close();
}else {
copy( $source, $target );
}
}
you can call this function with this example, lets say i want to copy my themes from my source files to my new websites i would do this:
PHP CODE
$source ='/var/www/source/theme';
$destination = '/var/www/newsite/theme/';
full_copy($source, $destination)
$destination = '/var/www/newsite/theme/';
full_copy($source, $destination)
Mar 08, 2008 Reply Report abuse
©2013 Webune Forums - Thu Jan 10, 2013 12:17 pm
Powered by: Webune Forums V3
Powered by: Webune Forums V3