<?php
//die();
require_once("../include/config.php");
require_once(GLOBAL_INCLUDE_PATH."include/startup.php");
require_once(GLOBAL_INCLUDE_PATH."imageUpload/foto_upload_script.php");

$foto_upload = new Foto_upload;

$json['size'] = '1048576'; //$_POST['MAX_FILE_SIZE'];
$json['img'] = '';         


$foto_upload->upload_dir = IMAGE_TEMP_PATH;
$foto_upload->foto_folder = PRESSCOVERAGE_IMAGE_PATH;
$foto_upload->thumb_folder = PRESSCOVERAGE_IMAGE_THUMB_PATH;
$foto_upload->extensions = array(".jpg", ".gif", ".png", ".jpeg");
$foto_upload->language = "en";
$foto_upload->x_max_size = 800;
$foto_upload->y_max_size = 800;
$foto_upload->x_max_thumb_size = 250;
$foto_upload->y_max_thumb_size = 250;

$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 = true; 

$nameextension = "usr-";

$productnameinfile = isset($_FILES['myfile']['filename'])?$_FILES['myfile']['filename']:$_FILES['myfile']['name'];
//$filename = strtotime("now").'-'.$nameextension;
$filename = $nameextension.'-'.strtotime("now");
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'];
	
?>
