diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index b87079f2712d1f6b03294e06c04bce58ae0c597b..411654af606bce47950b3319f601e4e3ed6e6db8 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -65,6 +65,9 @@ if($source) {
 	$target=$dir.'/'.$filename;
 	$result=OC_Filesystem::file_put_contents($target, $sourceStream);
 	if($result) {
+		if($target[0] != '/') {
+			$target = '/'.$target;
+		}
 		$meta = OC_FileCache::get($target);
 		$mime=$meta['mimetype'];
 		$id = OC_FileCache::getId($target);