0

Warning: unlink(user_images/): Permission denied in C:.How to solve unlike permission denied

if($imgFile)
    {
      $upload_dir = 'user_images/'; // upload directory 
      $imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
      $valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
      $userpic = rand(1000,1000000).".".$imgExt;
      if(in_array($imgExt, $valid_extensions))
      {     
        if($imgSize < 5000000)
        {
          unlink($upload_dir.$edit_row['userPic']);
          move_uploaded_file($tmp_dir,$upload_dir.$userpic);
        }
        else
        {
          $errMSG = "Sorry, your file is too large it should be less then 5MB";
        }
 }
Ekta Padaliya
  • 5,743
  • 3
  • 39
  • 51
Bipul Prasai
  • 1,101
  • 2
  • 9
  • 7

1 Answers1

0

Permission denied error happens because you're trying to delete a file without having enough/right permissions for doing that. Please see following two similar questions

How to get permission to use unlink()?

PHP unlink denied on localhost / windows

Community
  • 1
  • 1
Taimur Khan
  • 531
  • 8
  • 21