WP_Filesystem_Direct::copy()
Copies a file.
Method of the class: WP_Filesystem_Direct{}
No Hooks.
Return
true|false
. True on success, false on failure.
Usage
$WP_Filesystem_Direct = new WP_Filesystem_Direct(); $WP_Filesystem_Direct->copy( $source, $destination, $overwrite, $mode );
- $source(string) (required)
- Path to the source file.
- $destination(string) (required)
- Path to the destination file.
- $overwrite(true|false)
- Whether to overwrite the destination file if it exists.
Default: false - $mode(int|false)
- The permissions as octal number, usually 0644 for files,
0755 for dirs.
Default: false
Changelog
Since 2.5.0 | Introduced. |
WP_Filesystem_Direct::copy() WP Filesystem Direct::copy code WP 6.6.2
public function copy( $source, $destination, $overwrite = false, $mode = false ) { if ( ! $overwrite && $this->exists( $destination ) ) { return false; } $rtval = copy( $source, $destination ); if ( $mode ) { $this->chmod( $destination, $mode ); } return $rtval; }