Php How To Move Uploaded File To Another Folder

Php Code To Move Uploaded File To Another Directory


________________________________________________________


In this Php Tutorial we will see How To Move Uploded File To Another Folder Using Php .

I Use In This Tutorial:
- NetBeans IDE .
- XAMPP .


 




Php Source Code:

<?php

if(isset($_POST['moveFile']))
{
    $fileName = $_FILES['fileName']['name'];
    $tempName = $_FILES['fileName']['tmp_name'];
    
    if(isset($fileName))
    {
        if(!empty($fileName))
        {
            $location = "MyFilles/";
            if(move_uploaded_file($tempName, $location.$fileName))
            {
                echo 'File Uploaded';
            }
        }
    }
}

?>

<!DOCTYPE Html>
<html>
    <head>
        <title> PHP MOVE FILE </title>
    </head>
    <body>
    
        <form action="php_move_upload_file.php" method="post" enctype="multipart/form-data">
            <input type="file" name="fileName"><br><br>
            <input type="submit" name="moveFile" value="Upload">
        </form>
        
    </body>
</html>




php move file
                     




Share this

Related Posts

Previous
Next Post »

4 comments

comments
7 juin 2017 à 12:51 delete

100% Perfectly Worked !! :D

Thank U Very Much !! :D

Reply
avatar
27 juin 2017 à 23:19 delete

i have getting an error in line number 26
Notice: Undefined variable: search_result in C:\xampp\htdocs\d1\d6.php on line 27

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\d1\d6.php on line 27
please give a solution

Reply
avatar