Move File using php

We will learn how to move a file to another directory using php. In php we have rename() function to achieve this. I will show you how to move a file from current directory to another directory, i will call that directory ‘new_folder’

In above example we created two variables $currentFilePath and $newFilePath. The first contains path of the file to be moved and second variable holds path where this file needs to be moved. We will store the response from rename(), which returns a boolean value. Later we can use this value to determine and show a little message about the status of our file moving.

Posted in: PHP