2017-06-07 25 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'">