

Nextrek
@ 415
Nextrek / Android / SmartCharging / endPoints / nightly / upload_avatar.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
<?php require_once("repositories/UserRepository.php"); require_once("constants.php"); if (!array_key_exists("user_id", $_POST) || !array_key_exists("avatar_name", $_POST)) { $risposta["return"] = 1; $risposta["avatar_name"] = ""; echo json_encode($risposta); die(); } if(isset($_FILES['avatar_file'])) { $file = $_FILES['avatar_file']; if($file['error'] == UPLOAD_ERR_OK and is_uploaded_file($file['tmp_name'])) { move_uploaded_file($file['tmp_name'], $_SERVER['DOCUMENT_ROOT'].AVATAR_PATH.$_POST["avatar_name"]); } } $servername = "localhost"; $username = "smartcharging"; $password = "LXRLBaEAuRr7M7jY"; $conn; $risposta = array(); $user_repo; try { $conn = new PDO("mysql:host=".$servername.";dbname=smartcharging", $username, $password); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //echo "Connesso con successo al DB"; $user_repo = new UserRepository($conn); $risposta = $user_repo->setAvatar($_POST["user_id"], $_POST["avatar_name"]); } catch(PDOException $e) { echo $e->getMessage(); $risposta["return"] = 1; $risposta["avatar_name"] = ""; } echo json_encode($risposta); $conn = null; //Close the connection to the DBMS ?> |
Commits for Nextrek/Android/SmartCharging/endPoints/nightly/upload_avatar.php
Revision | Author | Commited | Message |
---|---|---|---|
415
![]() |
![]() |
Wed 22 Jul, 2015 08:27:42 +0000 | Piccolo refactor dei file php... |
400
![]() |
![]() |
Mon 20 Jul, 2015 10:23:38 +0000 | |
399
![]() |
![]() |
Mon 20 Jul, 2015 10:08:43 +0000 | Ora la upload_avatar.php e la upload_image.php puntano a una directory esterna. |
374 |
![]() |
Fri 17 Jul, 2015 08:20:18 +0000 | Creazione “branch” nightly |