0

多分私は愚かであるか、WAMP の制限またはブラウザーの制限のいずれかを誤解していますが、Ajax を使用して scandir 関数を再帰的に使用する PHP ファイル エクスプローラー ビューを作成しました。 .

http://localhostにアクセスするとファイルを起動できますが、同じ localhost マシンから http://[our_external_ip_address] にアクセスすると、ファイルが開きません。ステータス バーのパスは両方で同じように表示されます (例: file://computername/share/filename.zip)。最終的には、Web ホスト マシンと同じドメインにあるネットワーク共有にファイルを配置したいと考えています。

助けてください。私は PHP と JS にかなりの能力がありますが、Web ホストなどに関しては、詰め込みすぎです。ティア。

ジェームズ

4

1 に答える 1

1

DaveRandom に多大な感謝 - このソリューションは、UNC パスからの PDF / Word / Zip ファイルを外部 Web クライアントから起動できるように機能しました。

ファイル 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;
?>
于 2012-04-13T09:13:31.157 に答える