I am working on a Document management system. Documents are stored on the local network filesystem, and indexed using my software, which stores document information in a database. Currently, when the user views a document, a new window is popped up, and the window is redirected using header() to the UNC path of the document on the network.
For security reasons, I don't want to do this. I want to configure security so that only my application has read access to these files, so I can ensure that only authorized users can read the documents. My goal is to have PHP read the file from the network and then display the document.
Below is a snippet of code to do this:
$doc_path_name = $doc_info['doc_data_path'] . $file_name;
insert_doc_access($doc_id, $_SESSION['user']['user_id'], VIEW_DOCUMENT);
header("Content-Type: " . $format['doc_format_mime_type'] . "\n");
header("Content-Length: " . $doc_info['doc_file_size']);
header("Content-Disposition: inline; filename=" . $file_name);
readfile($doc_path_name);
$format['doc_format_mime_type'] contains the MIME type for the document. In the case of a PDF document, for instance, it is application/pdf.
I have tried various combinations of headers, including and excluding the filename in the content-disposition header, exclusing content-disposition, excluding content-length, but the documents are not displayed correctly.
In Mozilla, I am prompted to open the document, but the document that it opens in Acrobat or Word is gibberish. I want the document to be viewed inline in the browser window.
In IE, I am prompted to open or save the file, and the file name is the URL that was sent to IE (http://doctracker/lookup/doc_view.php?doc_id=76&version=3) and then I get an error that IE was unable to open the site.
I am told that IE has problems where it ignores the Content-type header that is sent, but I'm having problems finding information about this.
Has anyone done something similar to this? Any help would be appreciated!
Steve