PHP Mysql get the filename and unlink the file -


i have sql table contain name of files(the file exist in sever).

made checkbox list deleting data in sql table success.
fail delete file in server. want know reason , solution.

my code below:

if(isset($_post['id'])) { $id = trim($_post['id']);  $image_query = mysqli_query($conn, "select imagename table no in ($id)"); $image_result = mysqli_fetch_array($image_query);     while ($row = mysqli_fetch_assoc($image_result)) {         $imagename = $row['imagename'];         $file="image/$imagename";         unlink($file);     } $query = "delete table no in ($id)"; $qresult = mysqli_query($conn, $query) or die ("database error:". mysqli_error($conn));  echo $id; } 

give absolute path first. , please check first file exist or not. check below.

if(file_exist($file)) {     unlink($file); } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -