0
我有讀取該文件夾中的文件夾和文件的代碼。 基本上,這段代碼會做什麼,它會顯示所有文件。併爲它們創建鏈接。當我點擊鏈接文件時,將在瀏覽器中打開(如果支持,如圖像)或下載。 但問題是它顯示的文件,但沒有打開它們。 任何機構都可以突出顯示問題嗎? 這裏是完整的代碼。使用php讀取目錄和文件中的文件使用php
<?php
$msgz = "";
if($handle = opendir('.'))
{
while (false !== ($filez = readdir($handle)))
{
if (($filez != ".") && ($filez != ".."))
{
$msgz .= '<li><a href="'.$filez.'">'.$filez.'</a></li>';
}
}
closedir($handle);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>List files and directories inside the specified path in PHP</title>
</head>
<body>
<h2>List files and directories inside the specified path in PHP</h2>
<p>List of files:</p>
<ul>
<p><?php echo $msgz ?></p>
</ul>
</body>
</html>
這裏是瀏覽器的截圖。
image showing that link of the desired file is present in address bar but file is not open
你看到的結果究竟是什麼?此代碼適用於我。 –
這不是打開文件。就像我想打開一個jpeg文件,它應該在瀏覽器中打開,但它沒有。它只是在地址欄中顯示文件名稱。 – Uniquedesign
這聽起來更像是一個瀏覽器問題。那麼瀏覽器的文檔是什麼樣的?空白?屏幕截圖可以幫助 –