aboutsummaryrefslogtreecommitdiffstats
path: root/files/ajax/newfile.php
diff options
context:
space:
mode:
Diffstat (limited to 'files/ajax/newfile.php')
-rw-r--r--files/ajax/newfile.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/files/ajax/newfile.php b/files/ajax/newfile.php
new file mode 100644
index 00000000000..5c4f49a3675
--- /dev/null
+++ b/files/ajax/newfile.php
@@ -0,0 +1,27 @@
+<?php
+
+// Init owncloud
+require_once('../../lib/base.php');
+
+OC_JSON::checkLoggedIn();
+
+// Get the params
+$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
+$filename = isset( $_GET['filename'] ) ? $_GET['filename'] : '';
+$content = isset( $_GET['content'] ) ? $_GET['content'] : '';
+
+if($filename == '') {
+ OC_JSON::error(array("data" => array( "message" => "Empty Filename" )));
+ exit();
+}
+
+if(OC_Files::newFile($dir, $filename, 'file')) {
+ if($content){
+ OC_Filesystem::file_put_contents($dir.'/'.$filename,$content);
+ }
+ OC_JSON::success(array("data" => array('content'=>$content)));
+ exit();
+}
+
+
+OC_JSON::error(array("data" => array( "message" => "Error when creating the file" ))); \ No newline at end of file