title: Delete files in a hidden folder on a network drive using PHP?
body: <p>I'm trying to delete files in a hidden folder on a network drive using PHP. I have tried:<br>
  <code>$file = "\\network_drive\folder\hidden_folder$\my_file.pdf"; 
  unlink($file);
  </code></p>
  
  <p>PHP responds: <strong>Permission denied.</strong></p>
  
  <p>I then ran <code>print shell_exec('whoami');</code> to determine the user that PHP was running as. This returned: <strong>nt authority\system</strong>  </p>
  
  <p>In the file's security settings, I searched for 'nt authority' while trying to give permissions to 'nt authority/system', but this returned no results. I also tried searching for 'system', which returned a few users. I then added 'Full Control' permissions to the user named 'SYSTEM' to the file:  </p>
  
  <p><a href="https://i.stack.imgur.com/pDZNv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pDZNv.png" alt="Searching for the nt authority/system user"></a>
  <a href="https://i.stack.imgur.com/eRUaG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eRUaG.png" alt="Adding permissions for SYSTEM user"></a></p>
  
  <p>After giving SYSTEM 'Full Control' privileges, I ran <code>unlink($file);</code> again and PHP tells me that permission is still denied. </p>
  
  <p>I thought that the user named 'SYSTEM' would correspond to the 'nt authority/system' that PHP was talking about, but it looks like that's either not the case or there is something else I'm not taking into account here. I'm out of ideas on how to delete this file-- does anyone else have a suggestion on how to accomplish this?</p>