I have two servers, one runs an intranet on IIS7 (win 2008 server). I need this to be able to access PDF files stored on a second (windows) server. As the content of the PDF files are sensitive (they're payslips) I can't just create direct links to the files as users won't have actual access to the directory holding the PDFs. So instead I'm using PHP to get the file and present it for download.
If I put the PDF file on the local C drive of the intranet server, the code works. It gets the PDF file specified and allows me to download it. However, across server it just comes back with the php file that I'm running for download.
My code for reference is
$filename = realpath($pdfpath);
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($filename));
set_time_limit(0);
@readfile("$filename") or die("File not found.");
I've had a look online and have found several people trying to perform similar operations. The main suggestion we've seen and also read on the Microsoft site was to make the intranet server run as a specific local user (as opposed to the IIS User - IUSR) and then give them access to the folder on the network drive with the PDFs in. Tried this and it also doesn't work. My other thought was to somehow map a drive specific to the server, as obviously the intranet is accessed via a browser and users don't actually log into the intranet server.
I realise that this isn't standard due to the security risks but as this is all internal and limited to just a directory on a different server I would hope that there's still a way around it.
The paths I've tried have been
\\servername\directory\pathtopdf.pdf
\\\\servername\\directory\\pathtopdf.pdf
We also tried setting up the directory as a virtual directory within IIS7 and used ..\virtualdirectory\pathtopdf.pdf but again no joy, and to be honest I doubt it would as PHP isn't working via the browser but via the file system essentially.
Anyway, any suggestions or thoughts appreciated.
Just to add, we're running PHP 5.3.4 and I have full access to edit the php.ini file.
tia
