permission denied when i try to unlink an image in the folder using php

12 Views Asked by At

this is my code in image_display.php:

<?php
$conn=  mysqli_connect("localhost","root","","crud");
$query = mysqli_query($conn, "select * from upload");
while($data = mysqli_fetch_assoc($query)) {
  ?>
 <img src="http://localhost/server/file_upload/<?php echo $data['location'] ?>"
    height="200" width="200"/>
    <a href="delete.php?path=<?php echo $data['location'] ?>
    &id=<?php echo $data['id'] ?>">Delete</a>
<?php
}

?>

and in delete.php:

<?php
$path = $_GET['path'];
$id = $_GET['id'];
chown($path,777);
if(unlink($path)) {
    $conn=  mysqli_connect("localhost","root","","crud");
    $query = mysqli_query($conn, "delete from upload where id='$id'");
    header('location: show.php');
}

?>

it was working without any problem? suddenly shows me this warning and not deleted?

Warning: unlink(files/decoration.png ): Permission denied in C:\xampp\htdocs\server\file_upload\delete.php on line 5

how can I enter as an root or admin in windows?

0

There are 0 best solutions below