summaryrefslogtreecommitdiff
path: root/filenames.php
diff options
context:
space:
mode:
authorAdhitya Kamakshidasan2016-06-30 16:37:15 +0530
committerGitHub2016-06-30 16:37:15 +0530
commit1643dcd2803d9f19d52af25ebb64fb68e6e5fac8 (patch)
treedab899b1abcc60893073d595c4a51609d8444c38 /filenames.php
parentfaf27e6916000410fdfae9c7964fb9068ab3b77a (diff)
parent4a1a77706b7c7aafb9634917e564b5ccdc4da732 (diff)
downloadxcos-on-web-1643dcd2803d9f19d52af25ebb64fb68e6e5fac8.tar.gz
xcos-on-web-1643dcd2803d9f19d52af25ebb64fb68e6e5fac8.tar.bz2
xcos-on-web-1643dcd2803d9f19d52af25ebb64fb68e6e5fac8.zip
Merge pull request #97 from jiteshjha/repository-refactoring
Preloading-images-blocks-palettes-ds_files
Diffstat (limited to 'filenames.php')
-rw-r--r--filenames.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/filenames.php b/filenames.php
new file mode 100644
index 0000000..81ca89f
--- /dev/null
+++ b/filenames.php
@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * @jiteshjha
+ * filenames.php returns the names of all the files in a given folder
+ */
+
+// Store the filenames
+$filenameArray = [];
+
+// Get the folder to be operated
+$url = $_POST['url'];
+
+// Reference: http://php.net/manual/en/function.opendir.php
+// Open the file directory and get the filehandle
+$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);
+?>