

Nextrek
@ 378
Nextrek / Android / SmartCharging / endPoints / nightly / upload_image.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 |
<?php session_start(); require_once("constants.php"); //var_dump($_SESSION); /*if (!array_key_exists("images", $_SESSION)) { $_SESSION["images"] = array(); }*/ $image_filename = ""; $risposta = array(); $risposta["return"] = 0; if(isset($_FILES['image_file'])) { $file = $_FILES['image_file']; if($file['error'] == UPLOAD_ERR_OK and is_uploaded_file($file['tmp_name'])) { $imgExtention = substr(strrchr($file["name"],'.'),1); $image_filename = uniqid().".".$imgExtention; //echo session_id(); if (!file_exists(TEMP_IMAGES_PATH.session_id())) { mkdir(TEMP_IMAGES_PATH.session_id(), 0777, true); } move_uploaded_file($file['tmp_name'], TEMP_IMAGES_PATH.session_id()."/".$image_filename); //array_push($_SESSION["images"], $image_filename); } else { $risposta["return"] = 0; } } $risposta["image_file"] = $image_filename; echo json_encode($risposta); ?> |