简体   繁体   English

如何打开本地c驱动器中的pdf文件

[英]How to open a pdf file located in a local c drive

Background: Me and my two colleagues all have a folder on ours computer called: C:\\Synkade filer. 背景:我和我的两个同事在我们的计算机上都有一个文件夹:C:\\ Synkade filer。 So any file that is there, we all have access to. 因此,任何存在的文件,我们都可以访问。

Now I have created a small MySQL database that saves the path to a file on that local folder, for instance C:\\Synkade filer\\pdffiles\\file1.pdf 现在,我创建了一个小型MySQL数据库,该数据库将路径保存到该本地文件夹中,例如C:\\ Synkade filer \\ pdffiles \\ file1.pdf。

The php script I made has no problem in uploading new files into the *C:\\Synkade filer\\pdffiles* and saving the path information into MySQL. 我制作的php脚本在将新文件上传到* C:\\ Synkade filer \\ pdffiles *并将路径信息保存到MySQL中没有问题。 The idea is that when I click on a small pdf-icon the php script will get the path information from MySQL and open the file on the browser (firefox). 这个想法是,当我单击一个小的pdf图标时,php脚本将从MySQL获取路径信息并在浏览器(firefox)上打开文件。 Say the path information in MYSQL is: C://Synkade filer/pdffiles/file1.pdf The retrieving code is: 假设MYSQL中的路径信息为: C:// Synkade filer / pdffiles / file1.pdf检索代码为:

<a href="' . $row['fup']. '"><img src="./images/pdf_icon.gif" width="16" height="16" border="0" alt="PDF file" /></a>

, where $row['fup'] is the row information from MySQL. ,其中$ row ['fup']是来自MySQL的行信息。

The problem is that this doesn't work. 问题是这行不通。 Is it because the file is on a local drive (C:)? 是否因为文件位于本地驱动器(C :)上?

Before you ask: why not upload the files on my web server? 问之前:为什么不将文件上传到我的Web服务器上? The answer is that I would prefer not to. 答案是我不想这样做。 The pdf files do have sensitive information that we three only show have access to. pdf文件确实具有敏感信息,我们三个仅显示这些信息可以访问。 So it feels better that the pdf files are only accessible to us on our own computers. 因此,最好只能在我们自己的计算机上访问pdf文件。 The point is also that if someone else tries to open the pdf file, it simple will not find it since it will not exist on his/hers device. 重点还在于,如果其他人尝试打开pdf文件,由于它在他/她的设备上不存在,因此将无法找到它。

So my question is: Is there a way to make the access to the files from a local drive to work. 所以我的问题是:有没有一种方法可以使本地驱动器对文件的访问起作用。 Is this a script problem or is this a computer configuration issue? 这是脚本问题还是计算机配置问题?

I need to say that this is my first PHP-MySQL database ever, so my knowledge is limited. 我需要说的是,这是我有史以来第一个PHP-MySQL数据库,因此我的知识有限。 I am thankful for any help I can get. 我很感谢我能得到的任何帮助。

Sure: just write out a "file" URL format link to your .pdf file. 当然可以:只需在您的.pdf文件中写一个“文件” URL格式链接。

For example: 例如:

file:///C:/temp/ececnews.pdf

Corresponds to the windows file "c:\\temp\\ececnews.pdf" 对应于Windows文件“ c:\\ temp \\ ececnews.pdf”

Two handy functions are urlencode() and realpath(): 方便的两个函数是urlencode()和realpath():

Use file:/// in front of the path of your file. 在文件路径前面使用file:///。

http://www.w3schools.com/html/html_url.asp http://www.w3schools.com/html/html_url.asp

For example: 例如:

<a href="file:///' . $row['fup']. '"><img src="./images/pdf_icon.gif" width="16" height="16" border="0" alt="PDF file" /></a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM