diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-18 17:27:34 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-18 17:27:34 +0200 |
commit | 45de7ad221f9e505abdabcc5084dd12c80851469 (patch) | |
tree | 9afe2994fe01d35cf7aa2e16389c04bb3e298faf /apps/files/ajax/newfile.php | |
parent | dfc92675e0d76ad9550a274b712e084e1738831c (diff) | |
download | nextcloud-server-45de7ad221f9e505abdabcc5084dd12c80851469.tar.gz nextcloud-server-45de7ad221f9e505abdabcc5084dd12c80851469.zip |
move files to app folder
Diffstat (limited to 'apps/files/ajax/newfile.php')
-rw-r--r-- | apps/files/ajax/newfile.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php new file mode 100644 index 00000000000..472b577a32a --- /dev/null +++ b/apps/files/ajax/newfile.php @@ -0,0 +1,47 @@ +<?php + +// Init owncloud + + +OC_JSON::checkLoggedIn(); + +// Get the params +$dir = isset( $_POST['dir'] ) ? stripslashes($_POST['dir']) : ''; +$filename = isset( $_POST['filename'] ) ? stripslashes($_POST['filename']) : ''; +$content = isset( $_POST['content'] ) ? $_POST['content'] : ''; +$source = isset( $_POST['source'] ) ? stripslashes($_POST['source']) : ''; + +if($filename == '') { + OC_JSON::error(array("data" => array( "message" => "Empty Filename" ))); + exit(); +} + +if($source){ + if(substr($source,0,8)!='https://' and substr($source,0,7)!='http://'){ + OC_JSON::error(array("data" => array( "message" => "Not a valid source" ))); + exit(); + } + $sourceStream=fopen($source,'rb'); + $target=$dir.'/'.$filename; + $result=OC_Filesystem::file_put_contents($target,$sourceStream); + if($result){ + $mime=OC_Filesystem::getMimetype($target); + OC_JSON::success(array("data" => array('mime'=>$mime))); + exit(); + }else{ + OC_JSON::error(array("data" => array( "message" => "Error while downloading ".$source. ' to '.$target ))); + 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" ))); |