<?php



$a = date('Y');
$m = date('m');
$carpeta = "$m-$a";



include 'concha.php';
// A list of permitted file extensions
$allowed = array('jpg', 'jpeg', 'gif', 'png');

if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){

	$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);

	if(!in_array(strtolower($extension), $allowed)){
		echo '{"status":"error"}';
		exit;
	}

		$tempm = $_FILES['upl']['tmp_name'];
		  $mime = mime_content_type($tempm);


		 if ($mime == 'image/png' or $mime == 'image/jpeg' or $mime == 'image/gif') {} else {echo "no valido"; exit;}



	$hola = "hola.jpg";

	if(move_uploaded_file($_FILES['upl']['tmp_name'], "$dom/$carpeta/$mp3")){
		echo '{"status":"success"}';


		$mp3 = $hola;

		$mp3 = "$dom/$carpeta/$mp3";




 $ID_nota = $_POST['ID_nota'];



 include 'concha.php';



 $sSQL="UPDATE  `$basedatos`.`notas` SET  `foto` =  '$mp3' WHERE  `notas`.`ID` = '$ID_nota';";

$conn->query($sSQL);


 	include 'concha.php';



 $sSQL="UPDATE  `$basedatos`.`notas` SET  `carpetafoto` =  '$carpeta' WHERE  `notas`.`ID` = '$ID_nota';";

$conn->query($sSQL);



 

 $ext_img = $_SESSION['user_file_ext'];

 $sSQL="UPDATE  `$basedatos`.`notas` SET  `ext_img` =  '$extension' WHERE  `notas`.`ID` = '$ID_nota';";

 echo $sSQL;
$conn->query($sSQL);

		exit;
	}
}

echo '{"status":"error"}';
exit;
