非常感谢 DaveRandom - 该解决方案允许从外部 Web 客户端启动来自 UNC 路径的 PDF / Word / Zip 文件。
文件 1: - index.php
<?php
$filename= *** insert UNC path to file *** // e.g. \\share\computername\New Document.doc
$extension= pathinfo($filename, PATHINFO_EXTENSION); // Gets extension for file
$displayFilename= *** insert shorten filename *** // e.g. New Document.doc
?>
<a href="filehandler.php?name=<?php echo $filename; ?>&ext=<?php echo $extension; ?>&shortname=<?php echo $displayFilename; ?>"><?php echo $displayFilename; ?></a>
文件 2:-filehandler.php
<?php
$filename = $_GET['name'];
$extension = $_GET['ext'];
$shortfilename = $_GET['shortname'];
if ($extension == "pdf")
{
header("Content-type: application/pdf"); // act as a pdf file to browser
}
if ($extension == "doc")
{
header("Content-type: application/msword"); // act as a doc file to browser
}
if ($extension == "zip")
{
header("Content-type: application/zip"); // act as a zip file to browser
}
header("Content-Disposition: inline; filename='$shortfilename'");
$file = readfile($filename);
echo $file;
?>