Cannot upload img to a folder

Im using laravel. And the img wont upload to my public/imgs folder. It keeps saying Sorry, there was an error uploading your file.

// PHP CODE
$target_dir = "public/imgs/";
$target_file = $target_dir . basename($_FILES["img"]["name"]);


if (move_uploaded_file($_FILES["img"]["name"], $target_file)) {
     echo "success";
}
else {
    echo "Sorry, there was an error uploading your file.";
}

// HTML CODE
<form method="POST" action="/listings" enctype="multipart/form-data">
    <input type="file" name="img">
</form>

First make sure the upload dir is existing and writable; then file_uploads is on in php.ini

Maybe you should change your original move_uploaded_file function to

move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)

See the diff between name and tmp_name

<form method="POST" action="/listings" enctype="multipart/form-data">
    <input type="file" name="img">
</form>

HTML

$target_dir = "public/imgs/";
$target_file = $target_dir . basename($_FILES["img"]["name"]);
if ($_FILES['img']['error'] == 0) {
    if (move_uploaded_file($_FILES['img']['tmp_name'], $target_file)) {
        echo 'success';
    } else {
        echo 'upload failed<br>';
        echo '<pre>';
        echo 'tmp name: ';
        print_r($_FILES['img']['tmp_name']);
        echo "\n target: ".$target_file;
        echo "\n\n";
        print_r($_FILES['img']);
        echo '</pre>';
    }
} else {
    echo 'upload failed: ' . $_FILES['img']['error'];
}

PHP

This code should work and show all data for debugging.