<?php
include_once ("../../../config.php");
include_once ("../path.php");

$modelFolder = $_GET["folder"];
$filename = $_GET["filename"];

$imgFolder = $json_instance_path . $modelFolder . $images_dir . '/';

if (!is_dir($imgFolder)) mkdir($imgFolder, 0755, true);

$request_new_data = file_get_contents("php://input");
$file = fopen($imgFolder . $filename, "wb");
$data = explode(',', $request_new_data);

fwrite($file, base64_decode($data[1]));
fclose($file);

exit;