move a file in php

To move a file in PHP, you can use the rename() function which takes two arguments - the source file and the destination file.

Here's an example:

main.php
<?php
// specify the source file
$source = '/path/to/source/file.txt';

// specify the destination file
$destination = '/path/to/destination/file.txt';

// move the file
if(rename($source, $destination)) {
    echo 'File moved successfully!';
} else {
    echo 'Error moving file!';
}
?>
288 chars
15 lines

Make sure that the file has the necessary permissions and that the destination directory exists before running this code.

gistlibby LogSnag