diff options
Diffstat (limited to 'settings/ajax/newavatar.php')
-rw-r--r-- | settings/ajax/newavatar.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/settings/ajax/newavatar.php b/settings/ajax/newavatar.php index 4c8ff0c4169..bede15e499d 100644 --- a/settings/ajax/newavatar.php +++ b/settings/ajax/newavatar.php @@ -13,12 +13,19 @@ if(isset($_POST['path'])) { \OC_Avatar::setLocalAvatar($user, $path); OC_JSON::success(); } catch (Exception $e) { - OC_JSON::error(); + OC_JSON::error(array("msg" => $e->getMessage())); } } -} elseif (isset($_POST['image'])) { // upload a new image - \OC_Avatar::setLocalAvatar($user, $_POST['image']); - OC_JSON::success(); +} elseif (!empty($_FILES)) { // upload a new image + $files = $_FILES['files']; + if ($files['error'][0] === 0) { + $data = file_get_contents($files['tmp_name'][0]); + \OC_Avatar::setLocalAvatar($user, $data); + unlink($files['tmp_name'][0]); + OC_JSON::success(); + } else { + OC_JSON::error(); + } } else { OC_JSON::error(); } |