'Permission denied Read file on a network drive from php server for which just the user has read access to it
I want to open a file in a network drives with php. The file is not accessible for every one, just for one user. I have the following code:
$file = "$dir/$fileName";
$fp = fopen($file, "r");
if ( !$fp ) {
throw new Exception('File open failed.');
}
$str = stream_get_contents($fp);
fclose($fp);
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $fileName . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
exit;
The result: failed to open stream: Permission denied
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
