What steps should be taken to troubleshoot and diagnose the issue of move_uploaded_file() function not working in a PHP upload form?

The move_uploaded_file() function not working in a PHP upload form could be due to incorrect file permissions, incorrect file path, or exceeding the upload_max_filesize or post_max_size limits in the php.ini file. To troubleshoot and diagnose the issue, you should check the file permissions, verify the file path, and ensure that the uploaded file size does not exceed the limits set in the php.ini file.

<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);

if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
    echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
} else {
    echo "Sorry, there was an error uploading your file.";
}
?>