Nextrek
@ 374
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 |
<?php require_once("UserRepository.php"); if (!array_key_exists("user_id", $_POST) || !array_key_exists("url", $_POST)) { $risposta["return"] = 1; $risposta["avatar_path"] = ""; 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'], $_POST["url"]); } } $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["url"]); } catch(PDOException $e) { echo $e->getMessage(); $risposta["return"] = 1; $risposta["avatar_path"] = ""; } 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 |
---|---|---|---|
374 | FSallustio | Fri 17 Jul, 2015 08:20:18 +0000 | Creazione “branch” nightly |