summaryrefslogtreecommitdiff
path: root/getFilename.php
diff options
context:
space:
mode:
authorjiteshjha2016-06-30 15:46:15 +0530
committerjiteshjha2016-06-30 15:46:15 +0530
commit981429df495c0b30b4a0a3cfc4cdaf3d096b834b (patch)
tree1849e4104dbc39f2963bac43a3ce69a9358c04db /getFilename.php
parenta45361eb58f86535805185d16b91ae05339e7771 (diff)
downloadxcos-on-web-981429df495c0b30b4a0a3cfc4cdaf3d096b834b.tar.gz
xcos-on-web-981429df495c0b30b4a0a3cfc4cdaf3d096b834b.tar.bz2
xcos-on-web-981429df495c0b30b4a0a3cfc4cdaf3d096b834b.zip
Preloading-images-blocks-palettes-ds_files
Diffstat (limited to 'getFilename.php')
-rw-r--r--getFilename.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/getFilename.php b/getFilename.php
new file mode 100644
index 0000000..3355ac3
--- /dev/null
+++ b/getFilename.php
@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * @jiteshjha
+ * getFilename returns the names of all the files in a given folder
+ */
+
+// Store the filenames
+$filenameArray = [];
+
+// Get the folder to be operated
+$url = $_POST['url'];
+
+// Open the file directory and get the filehandle
+// Reference: http://php.net/manual/en/function.opendir.php
+$handle = opendir(dirname(realpath(__FILE__)).$url);
+
+// For each file in the folder, push the filename to filenameArray
+while($file = readdir($handle)){
+ if($file !== '.' && $file !== '..'){
+ array_push($filenameArray, "$url$file");
+ }
+}
+
+// Return the file name array in JSON format
+echo json_encode($filenameArray);
+?>