I am using PHP4 on win2k plateform.
I want to move existing files from one folder to another. How can i
achive that by using PHP? I am not doing (and donot want to) uploading
of files via HTML Form , nor i want to use ftp. It is simply , moving
of existing files from one folder to another.All file system
permission are in our favours , no restrictions.
ssp2000
As written in the documentation.
<?php
rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt");
?>
Check www.php.net and go to documentation on 'file', you will also find ways
to get a directorylisting. You'll need a directorylisting to get all
filenames.
finding files in a directory:
1) glob:
<?php
foreach (glob("*.txt") as $filename) {
echo "$filename size " . filesize($filename) . "\n";
}
2) opendir
<?php
$dir = "/tmp/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) .
"\n";
}
closedir($dh);
}
}
?>
Regards,
Erwin
> Thanks for you input. glob requires PHP 4 >= 4.3.0
In that case use: opendir
But I guess you figured that yourself. :P
Good luck.
Regards,
Erwin Moller