How to upload image to database using php and mysql? [duplicate]

Make sure you have set form attribute enctype="multipart/form-data".

This attribute help you to get files from user.

<form action="PATH" method="post" enctype="multipart/form-data"></form>

Change your PHP script as below and try

<?php 
    if(isset($_POST['submit'])){
        $name       = $_FILES['file']['name'];  
        $temp_name  = $_FILES['file']['tmp_name'];  
        if(isset($name) and !empty($name)){
            $location = '../uploads/';      
            if(move_uploaded_file($temp_name, $location.$name)){
                echo 'File uploaded successfully';
            }
        } else {
            echo 'You should select a file to upload !!';
        }
    }
?>

this happens due to the size of the file :

max_execution_time = 300
max_input_time = 240
post_max_size = 128M upload_max_filesize = 128M

in your php.ini file you should change above codes according to your requirement...