FILES Variable and move_uploaded_file tutorial in php

 <?php


//When we want to upload any image or document at that time enctype="multipart/form-data"
// property is required in form as shown below:

if(isset($_FILES["image"]))
{
    echo "<pre>";
    print_r($_FILES);
    echo "</pre>";

    $file_name = $_FILES["image"]["name"];
    $file_size = $_FILES["image"]["size"];
    $file_tmp = $_FILES["image"]["tmp_name"];
    $file_type = $_FILES["image"]["type"];

    if(move_uploaded_file($file_tmp, "upload_images/".$file_name))
    {
        echo "Successfully Uploaded.";
    }
    else
    {
        echo "Could not upload!";
    }
}
?>

<html>
    <body>
        <form action="" method="POST" enctype="multipart/form-data">
            <input type="file" name="image"><br><br>
            <input type="submit">
        </form>
    </body>
</html>



Comments

Popular posts from this blog

Logical_Operators

Get Functions

print_Statement