diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index dde5d3c50af32e032567a812ce1be2465e96b13b..1d03cd89f83c9510b3f2a640ce5158eb95cb2c5e 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -105,16 +105,20 @@ if (strpos($dir, '..') === false) {
 			$meta = \OC\Files\Filesystem::getFileInfo($target);
 			// updated max file size after upload
 			$storageStats = \OCA\files\lib\Helper::buildFileStorageStatistics($dir);
-
-			$result[] = array('status' => 'success',
-				'mime' => $meta['mimetype'],
-				'size' => $meta['size'],
-				'id' => $meta['fileid'],
-				'name' => basename($target),
-				'originalname' => $files['name'][$i],
-				'uploadMaxFilesize' => $maxUploadFileSize,
-				'maxHumanFilesize' => $maxHumanFileSize
-			);
+			if ($meta === false) {
+				OCP\JSON::error(array('data' => array_merge(array('message' => $l->t('Upload failed')), $storageStats)));
+				exit();
+			} else {
+				$result[] = array('status' => 'success',
+					'mime' => $meta['mimetype'],
+					'size' => $meta['size'],
+					'id' => $meta['fileid'],
+					'name' => basename($target),
+					'originalname' => $files['name'][$i],
+					'uploadMaxFilesize' => $maxUploadFileSize,
+					'maxHumanFilesize' => $maxHumanFileSize
+				);
+			}
 		}
 	}
 	OCP\JSON::encodedPrint($result);
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index f262f11f06539a112f3a13f6656127f1c743a63a..1e6ab74fb6d92e59a8f5afb2c8d18f9b376525b8 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -102,6 +102,18 @@ $(document).ready(function() {
 			var result=$.parseJSON(response);
 
 			if(typeof result[0] !== 'undefined' && result[0].status === 'success') {
+				var filename = result[0].originalname;
+
+				// delete jqXHR reference
+				if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
+					var dirName = data.context.data('file');
+					delete uploadingFiles[dirName][filename];
+					if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
+						delete uploadingFiles[dirName];
+					}
+				} else {
+					delete uploadingFiles[filename];
+				}
 				var file = result[0];
 			} else {
 				data.textStatus = 'servererror';
@@ -109,20 +121,6 @@ $(document).ready(function() {
 				var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
 				fu._trigger('fail', e, data);
 			}
-
-			var filename = result[0].originalname;
-
-			// delete jqXHR reference
-			if (typeof data.context !== 'undefined' && data.context.data('type') === 'dir') {
-				var dirName = data.context.data('file');
-				delete uploadingFiles[dirName][filename];
-				if ($.assocArraySize(uploadingFiles[dirName]) == 0) {
-					delete uploadingFiles[dirName];
-				}
-			} else {
-				delete uploadingFiles[filename];
-			}
-
 		},
 		/**
 		 * called after last upload
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 7384b094cb04dd74049f4394ce5429622a85c1e2..d91acbbb2bdb708d2de8bf58705c667fe536a23e 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -362,9 +362,13 @@ class Shared extends \OC\Files\Storage\Common {
 				case 'xb':
 				case 'a':
 				case 'ab':
-					if (!$this->isUpdatable($path)) {
-						return false;
-					}
+				$exists = $this->file_exists($path);
+				if ($exists && !$this->isUpdatable($path)) {
+					return false;
+				}
+				if (!$exists && !$this->isCreatable(dirname($path))) {
+					return false;
+				}
 			}
 			$info = array(
 				'target' => $this->sharedFolder.$path,