2017-06-07 29 views
0

我正在使用MAMP Pro來管理在本地機器上構建網站,而不是在實際的網頁上。目前,我正在通過提供指向文件正確URL的鏈接來顯示文件。我想知道如何在鏈接到已經上傳到服務器的文件時模擬真實的Web服務器的行爲。通過<a>顯示上傳的文件

<!DOCTYPE html> 
<html> 

<head> 
    <meta charset="utf-8"> 
    <title>Total </title> 
     <link type="text/css" rel="stylesheet" href="course.css"> 
     <script src="../jquery.js"></script> 
     <script src="../jquery-ui.js"></script> 

</head> 
<body> 


<?php 
    if ($handle = opendir('../uploads')) 
    { 
     while (false !== ($entry = readdir($handle))) 
    { 

     if ($entry != "." && $entry != "..") 
     {     

      $real= realpath($entry); 


      echo "<button class='files accordian'>$entry</button> 
        <div class='panel'>"; 

      echo '<a href="'.$real.'"><button class="current-file" name="sent" value="View-Current-File"><img class="view-file-img" src="../images/magnify.png">View Current File</button></a>'; 
     } 

    }  
} 

?> 
</body> 
</html> 

此代碼將產生錯誤 「未找到

請求的URL /應用程序/ MAMP/htdocs中/ tutorvid /上傳/ Applicatgion Text.pages在此服務器上找到。」但是當我檢查該文件是在這個位置

回答

0

這工作:真實路徑()是沒有必要的

<a href="../uploads/'.$entry'">