Many other standard command-line functions of many operating systems are available in PHP. This not only includes chmod() and chgrp(), but also the following file system operations:
The preceding code duplicates the current file, moves it (or renames it), and finally deletes the resulting file. Copying, Moving, and Deleting Files (copymovedelete.php)<?php $filename = 'php.ini'; $tempname1 = $filename . rand(); $tempname2 = $filename . rand(); copy($filename, $tempname1); echo "Copied to $tempname1<br />"; rename($tempname1, $tempname2); echo "Moved to $tempname2<br />"; unlink($tempname2); echo "File deleted."; ?> |