php move_uploaded_file to another directory code example

Example 1: php move_uploaded_file

$upload_folder = "upload/";
$file_location = $upload_folder . basename($_FILES["fileToUpload"]["name"]);

     if(isset($_FILES['fileToUpload'])){ 

        if(move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $file_location)){
            
            echo 'Files has uploaded'; 
        };

     }

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