<?php
require_once "../include/config.php";
    require_once GLOBAL_INCLUDE_PATH."include/startup.php";


require_once GLOBAL_INCLUDE_PATH."js/foto_upload_script.php";

$foto_upload = new Foto_upload;


$json['size'] = '10485760';
$json['img'] = '';


$foto_upload->upload_dir = TEMP_IMAGE_PATH;
$foto_upload->foto_folder = POST_IMAGE_PATH;
$foto_upload->thumb_folder = POST_IMAGE_THUMB_PATH;
$foto_upload->extensions = array(".jpg", ".png", ".jpeg");
$foto_upload->language = "en";
// $foto_upload->x_max_size = 300;
// $foto_upload->y_max_size = 240;
// $foto_upload->x_max_thumb_size = 150;
// $foto_upload->y_max_thumb_size = 150;

$foto_upload->x_max_size = 800;
$foto_upload->y_max_size = 600;
$foto_upload->x_max_thumb_size = 800;
$foto_upload->y_max_thumb_size = 600;     

$foto_upload->the_temp_file = $_FILES['myfile']['tmp_name'];
$foto_upload->the_file = strtotime("now").'-'.$_FILES['myfile']['name'];
$foto_upload->http_error = $_FILES['myfile']['error'];
$foto_upload->rename_file = false; 

//$nameextension = "upload_blog";

//$filename = $nameextension."-".strtotime("now");
//print_r($foto_upload);
//exit;
if ($foto_upload->upload($filename)) {
    $foto_upload->process_image(false, true, true, 80);
	$json['img'] = $foto_upload->file_copy;
}

$json['error'] = strip_tags($foto_upload->show_error_string());
echo $json['img'];
//echo $filename.'.webp';
?>