为什么在Plesk Cpanel中我的连接正确时,图像上传会将错误视为“500内部服务器错误”

I have been Trying to upload an image in Plesk Cpanel from Godaddy. however, it gives me an error as " 500 Internal Server Error"

I checked my DB connections and they are perfect.

My code goes as:

<?php 
 include('../db.php'); 
  include('productadd.php'); 

$name = $_POST['name'];
$cat = $_POST['cat'];

$position = $_POST['position'];
$description = $_POST['description'];

$date = date_default_timezone_set('Asia/Kolkata');
$date = date('M-d,Y H:i:s');
$date2 = date('M-d,Y');

$file=($_FILES['file']['name']);

$conn = new mysqli ($servername, $dbusername, $dbpassword, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO products (name, cat, position, description, pic, date)
VALUES ('$name', '$cat', '$position', '$description', '$file', '$date2')";

if ($conn->query($sql) === TRUE) {

$target_dir = "../images/products/";

$target_file2 = $target_dir . basename($_FILES["file"]["name"]);
$uploadOk2 = 1;
$imageFileType2 = strtolower(pathinfo($target_file2,PATHINFO_EXTENSION));

if ($uploadOk2 == 0) {
    echo "Sorry, your file was not uploaded.";
// if everything is ok, try to upload file
} else {
    if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file2)) {

echo '<script language="javascript">';
echo 'alert("Product has been Added successfully.")';
echo '</script>';
echo '<a href="productadd.php"></a>';

} else {
        echo "Sorry, there was an error uploading your file.";
    }
}

}
else {

}

?>

Here as you can see, I have a query for "insert" into a database which works fine and inserts a row in the DB along with the image name, but the file moving/uploading isn't working well.

If I try removing the file upload code and checked, it works fine by inserting the query in DB.