How to use PHP & Copy() Copy File Learn how to use the PHP to Copy File on web server and using function copy()
ShotDev Focus:
- PHP & Copy File (Copy())
Example
php_copy_file.php
- <html>
- <head>
- <title>ShotDev.Com Tutorial</title>
- </head>
- <body>
- <?
- $flgCopy = copy("shotdev/my.txt", "shotdev/my_bak.txt");
- if($flgCopy)
- {
- echo "file copied.";
- }
- else
- {
- echo "Cannot copy file.";
- }
- ?>
- </body>
- </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_copy_file.php
Screenshot