summaryrefslogtreecommitdiff
path: root/filenames.php
diff options
context:
space:
mode:
authorkamakshidasan2016-12-22 15:36:18 +0530
committerkamakshidasan2016-12-22 15:36:18 +0530
commitb2cd0d0cad32683971baf53efa2e50ff8d26f66b (patch)
treee359be4308ae9b361eae39bf277adcfbef807cef /filenames.php
parent25afcccb46a603cc9d2485e25216acfffa2e3e02 (diff)
downloadxcos-on-web-b2cd0d0cad32683971baf53efa2e50ff8d26f66b.tar.gz
xcos-on-web-b2cd0d0cad32683971baf53efa2e50ff8d26f66b.tar.bz2
xcos-on-web-b2cd0d0cad32683971baf53efa2e50ff8d26f66b.zip
Maven has been removed
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);
+?>