Subversion Repository Public Repository

Nextrek

Diff Revisions 374 vs 399 for /Android/SmartCharging/endPoints/nightly/upload_avatar.php

Diff revisions: vs.
  @@ -1,10 +1,11 @@
1 1 <?php
2 2
3 3 require_once("UserRepository.php");
4 + require_once("constants.php");
4 5
5 - if (!array_key_exists("user_id", $_POST) || !array_key_exists("url", $_POST)) {
6 + if (!array_key_exists("user_id", $_POST) || !array_key_exists("avatar_name", $_POST)) {
6 7 $risposta["return"] = 1;
7 - $risposta["avatar_path"] = "";
8 + $risposta["avatar_name"] = "";
8 9 echo json_encode($risposta);
9 10 die();
10 11 }
  @@ -14,7 +15,7 @@
14 15 $file = $_FILES['avatar_file'];
15 16 if($file['error'] == UPLOAD_ERR_OK and is_uploaded_file($file['tmp_name']))
16 17 {
17 - move_uploaded_file($file['tmp_name'], $_POST["url"]);
18 + move_uploaded_file($file['tmp_name'], AVATAR_PATH.$_POST["avatar_name"]);
18 19 }
19 20 }
20 21
  @@ -32,14 +33,14 @@
32 33 //echo "Connesso con successo al DB";
33 34
34 35 $user_repo = new UserRepository($conn);
35 - $risposta = $user_repo->setAvatar($_POST["user_id"], $_POST["url"]);
36 + $risposta = $user_repo->setAvatar($_POST["user_id"], $_POST["avatar_name"]);
36 37
37 38 }
38 39 catch(PDOException $e)
39 40 {
40 41 echo $e->getMessage();
41 42 $risposta["return"] = 1;
42 - $risposta["avatar_path"] = "";
43 + $risposta["avatar_name"] = "";
43 44 }
44 45
45 46 echo json_encode($risposta);