I wanna delete the file from the uploads folder before deleting the row data from the database. I used the below code but its giving the error. Error=> No such file or directory
function deleteItem($conn,$product_id)
{
$stmtgetfile=$conn->prepare("SELECT * FROM tbl_item WHERE product_id=:product_id");
$stmtgetfile->bindParam('product_id',$product_id);
$stmtgetfile->execute();
$row = $stmtgetfile->fetch(PDO::FETCH_ASSOC);
$item=$row['product_photo'];
$path="../uploads/".$item;
unlink($path);
// $stmtdelete=$conn->prepare("DELETE FROM tbl_item WHERE product_id=:product_id");
// $stmtdelete->bindParam('product_id',$product_id);
// if($stmtdelete->execute())
// return true;
// return false;
}