Move Files Using PHP Code

by | Feb 26, 2012 | 1 comment

Hi, Today I am going to talk about how to move files with php
There are two ways to do it.

1. Copy and Delete

First you have to copy that file you want to move to where you want and then delete the old copy.


$file = 'folder1/example.txt';
$newfile = 'folder2/example.txt';
copy($file, $newfile);

2. Using Rename Function

This one is easier than the first one.You have to give the path of the file that you want to move in the first parameter of the rename() function.
Then give the new path for the file in the second parameter (give the path with the file name).


$file = 'folder1/example.txt';
$newfile = 'folder2/example.txt';

. . .

This was originally posted on one of my old blog –

1 Comment

  1. Sajjad Hossain

    eitai valo copy er ceye!


Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Goodreads Updates

Goodreads Read Shelf