php move file to folder code example

Example 1: php move file

//Use the rename() function.
rename('first_location/image1.jpg', 'new_location/image1.jpg');

Example 2: PHP Move File from One Folder to Another

<?php  /* Store the path of source file */$filePath = 'images/test.jpeg';  /* Store the path of destination file */$destinationFilePath = 'copyImages/test.jpeg';  /* Move File from images to copyImages folder */if( !rename($filePath, $destinationFilePath) ) {      echo "File can't be moved!";  }  else {      echo "File has been moved!";  }   ?>

Tags:

Php Example