开发者

need php code to obtain list of files stored on the server [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_运维知识库 Closed 11 years ago.

How to display the list of files stored in the folder on the server using php and making a call to that php page using ajax so as to display the list of files to the user on the client machine?


A very simple example:

http://jfcoder.com/test/showfilesget.php

showfiles.php

<?php 

// open this directory 
$dir = opendir("files");

// get each entry
while($file = readdir($dir)) {
    if (substr($file, 0, 1) != '.') {
        print "$file\n";
    }
}

// close directory
closedir($dir);

?>

showfilesget.php

<script type="text/javascript">

$(document).ready(function(){
    $('#loadfiles').click(function(){
        $.get('http://jfcoder.com/test/showfiles.php', function(data) {
            $('#files').html(data);
        });
    });
});

</script>

<h1>Loaded Files</h1>
<pre id="files"></pre>
<p><span class="link" id="loadfiles">Load files content</span></p>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜