summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2013-08-08 22:13:53 +0200
committerAndreas Fischer <bantu@owncloud.com>2013-08-08 22:13:53 +0200
commit0718c92dc805f7379b1dbffcd35155dc7e828b9f (patch)
tree175d0c3aac2225ed225ae10485b15f883bdb9c10 /apps
parenta2ac5e016334429892ac84bafa2644d8d39e6eb2 (diff)
downloadnextcloud-server-0718c92dc805f7379b1dbffcd35155dc7e828b9f.tar.gz
nextcloud-server-0718c92dc805f7379b1dbffcd35155dc7e828b9f.zip
Do not repeat definition of $target.
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/newfile.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 8548fc95ddf..8ee4888b34d 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -54,6 +54,8 @@ function progress($notification_code, $severity, $message, $message_code, $bytes
}
}
+$target = $dir.'/'.$filename;
+
if($source) {
if(substr($source, 0, 8)!='https://' and substr($source, 0, 7)!='http://') {
OCP\JSON::error(array("data" => array( "message" => "Not a valid source" )));
@@ -62,7 +64,6 @@ if($source) {
$ctx = stream_context_create(null, array('notification' =>'progress'));
$sourceStream=fopen($source, 'rb', false, $ctx);
- $target=$dir.'/'.$filename;
$result=\OC\Files\Filesystem::file_put_contents($target, $sourceStream);
if($result) {
$meta = \OC\Files\Filesystem::getFileInfo($target);
@@ -76,14 +77,14 @@ if($source) {
exit();
} else {
if($content) {
- if(\OC\Files\Filesystem::file_put_contents($dir.'/'.$filename, $content)) {
- $meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
+ if(\OC\Files\Filesystem::file_put_contents($target, $content)) {
+ $meta = \OC\Files\Filesystem::getFileInfo($target);
$id = $meta['fileid'];
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id)));
exit();
}
- }elseif(\OC\Files\Filesystem::touch($dir . '/' . $filename)) {
- $meta = \OC\Files\Filesystem::getFileInfo($dir.'/'.$filename);
+ }elseif(\OC\Files\Filesystem::touch($target)) {
+ $meta = \OC\Files\Filesystem::getFileInfo($target);
$id = $meta['fileid'];
OCP\JSON::success(array("data" => array('content'=>$content, 'id' => $id, 'mime' => $meta['mimetype'])));
exit();