ajax - need php code to obtain list of files stored on the server -
How to display a list of files stored in the folder on the server on PHP and call that php page by using AJAX So that the list of users' files can be displayed on the customer's machine?
Very simple example:
Showfiles.php showfilesget.php
& lt ;? Php // Open this directory $ dir = opendir ("files"); // Get every entry ($ file = readdir ($ dir)) {if (substr ($ file, 0, 1)! = '.') {Print "$ file \ n"; }} // close the closed directory ($ dir); ? & Gt;
& lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ('# loadfiles'). Click (function () {$ .get ('http://jfcoder.com/test/showfiles.php', function) {$ ('# Files') .html (data);});});}); & Lt; / Script & gt; & Lt; H1 & gt; Loaded Files & lt; / H1> & Lt; Pre id = "file" & gt; & Lt; / Pre & gt; & Lt; P & gt; & Lt; Span class = "link" id = "loadfiles" & gt; Load Files Content & lt; / Span & gt; & Lt; / P & gt;
Comments
Post a Comment