Welcome to mirror list, hosted at ThFree Co, Russian Federation.

newfile.php « ajax « files - github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5c4f49a3675ce307f9ef8a1a42ae6880abb1001d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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" )));