I have PDF documents stored in a shared folder in a server where I need to access them from a web application through file browsing. I know the names of the files stored there. So my link would be like (file:\\server\folder\abc.pdf).
My php application is in a web server running on xampp. But the shared folder is in a different domain. (Not in the web server folder - Normal file folder). When I try to access a file it says "Cannot find file:\\server\folder\abc.pdf. Make sure the path or Internet address is correct".
<a href="file:\\server\folder\abc.pdf" >Load File</a>
<?php
echo $dir = '\\\\server\\folder\\';
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
echo "<a href=".$dir.$file.">".$file."<br></a>";
}
closedir($dh);
?>
When I type "\\server\folder" on the address bar it prompts for the username and password of that folder since it is in the different domain (My current domain is already authenticated on my sign on). When I provide windows authentication to that folder, my web application url will work and opens up the file successfully.
I want to achieve this task without prompting the directory security username and password. My web application will be used by many users so locally mapping of network drive will also not feasible.
Can anyone help me on this please?
Got the Answer
We can map the network drive to the server and save the username and password which is prompted in the "map network drive" wizard and then can use mapped network wizard normally.
Below is the code that worked for me.
$dir = "A:/folder/";
$dh = opendir($dir);
while (($file = readdir($dh)) !== false)
{
echo 'The file is : ' . $file . "\n";
}
closedir($dh);