mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 00:25:18 +00:00
User can upload a new account image
This commit is contained in:
@ -213,6 +213,31 @@ class SettingsController {
|
||||
return $this->AccountImageSettingsToAPI($settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new account image for the user
|
||||
*
|
||||
* @url POST /settings/upload_account_image
|
||||
*/
|
||||
public function upload_account_image(){
|
||||
|
||||
//Login required
|
||||
user_login_required();
|
||||
|
||||
//Check if it is a valid file
|
||||
if(!check_post_file("picture"))
|
||||
Rest_fatal_error(400, "An error occured while receiving image !");
|
||||
|
||||
//Try to save image
|
||||
$file_uri = save_post_image("picture", 0, "avatars", 800, 800);
|
||||
|
||||
//Update account image information
|
||||
if(!components()->accountImage->update(userID, substr(strrchr($file_uri, "/"), 1)))
|
||||
Rest_fatal_error(500, "An error occured while trying to apply new account image !");
|
||||
|
||||
//Success
|
||||
return array("success" => "The new account image has been successfully saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a GeneralSettings object into a valid API object
|
||||
*
|
||||
|
Reference in New Issue
Block a user