sunucu php dosya yolu

2 Cevap

I am trying to get this script to work. it opens up a directry and lists the files in the directory. I have copied this code from somewhere else and the problem is that this php file is hosted on an apache server not my localhost. what is the correct $dir_name = "c:/"; to use?

Dosyası bu dizin / etki / domainxxxx.com.au / public_html / lsitfiles.php yüzden domainxxxx.com.au / public_html / lsitfiles.php kullanmak istiyorsunuz var?

<?php

$dir_name = "c:/";

$dir = opendir($dir_name);

$file_list = "<ul>";

while ($file_name = readdir($dir)) {
    if(($file_name != ".") && (file_name != "..")) {
    $file_list .= "<li>$file_name"; 
                               }
}

$file_list.= "<ul>";

closedir($dir);

?>

<HTML>
<BODY>

<p>Files in: <? echo "$dir_name"; ?></p>
<? echo "$file_list"; ?>


</BODY>
</HTML>

2 Cevap

Taramak istediğiniz klasörü bağlıdır.

Açıkçası, istemci bilgisayarda herhangi bir klasör tarama olamaz. Bunu biliyorum sanırım.

Eğer komut dosyası kullanmak en iyisidir bulunduğu klasörü taramak istiyorsanız:

$dir_name = dirname(__FILE__);

$dir_name taramak istediğiniz klasör. Eğer upload script nerede, sen yukarı ve mesela ../foldername veya myfolder/myfolder2 geriye mutlak veya göreceli yolları kullanarak oradan klasörleri belirtebilirsiniz.