How to copy a file from one directory to another using PHP?

Click Upvote

Say I've got a file test.php in foo directory as well as bar. How can I replace bar/test.php with foo/test.php using PHP? I'm on Windows XP, a cross platform solution would be great but windows preferred.

Pascal MARTIN

You could use the copy() function :

// Will copy foo/test.php to bar/test.php
// overwritting it if necessary
copy('foo/test.php', 'bar/test.php');


Quoting a couple of relevant sentences from its manual page :

Makes a copy of the file source to dest.

If the destination file already exists, it will be overwritten.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Copy file from one directory to another using cmd in C#

How to copy a file from one directory to another with VBA

How do I copy the latest file from one directory to another?

How can I copy a file from another directory to the current one?

How to copy data from one directory to another using nodejs fs?

How to copy and rename a file from one folder to another using Powershell?

batch file failed and cannot copy file from one directory to another

How to copy SELinux context from one directory and apply it to another directory?

How do i copy files from one directory to another directory?

How to copy file from one use to another?

Shell script Copy file from one directory to another not working

Copy a file from one directory to another in C++

FileNotFoundException While trying to copy the file from one directory to another

PHP copy files from one directory to another throws error

How to select and copy files with specific file names from one directory to another?

How to copy files from one directory to another after closing the Dolphin file manager in Kubuntu 16.04 LTS?

How to copy a file from one directory to another through crontab's reboot

How to copy and add prefix to file names in one step from another directory?

How to copy a directory from one hard drive to another with every single file?

How to copy things from one remote directory to another in the same server using WinSCP .NET assembly in C#

Copy file from directory to another using cmd command

How to copy all of the files from one directory to another in a bash script

How to copy the latest 2 directories from one directory to another?

How to copy files with a particular extension from one directory to another in linux

Powershell: How to copy files from one Directory to another

How can I copy one file from one folder to another within an Azure Fileshare using C#?

How to move one file from a directory to another no R using just a part of the file name?

How to copy file attributes from one file to another in Java?

Using ffmpeg to copy metadata from one file to another