php - Display directory structure to admin -


i developing cms in hav show administrator directory structue of root folder. im doing getting directory structure using php , trying print on client web page using javascript (echo"<script>javafunc()</script>") , after visiting different forums, see people saying not gud idea call javascript php!! so? if yes wats shud proper way displaying server directory structure, @ client side?

would idea echo array of directory names json array, compile array in php json_encode() in php.

$directories = array('file1', 'file2'); echo json_encode($directories); 

then data using ajax @ client side , format how want. (jquery example)

$.ajax({     url: 'ajax.php',     success: function(return_data)     {         // return_data has directories     } }); 

be careful don't allow people trick server listing ie. root folder or worse using functions realpath() , basename() , proper validation.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -