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


require_once("foto_upload_script.php");

$foto_upload = new Foto_upload;

	$fname   = $_REQUEST['filename'];
	$filenameid   = $_REQUEST['filenameid'];

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


$foto_upload->upload_dir = IMAGE_TEMP_PATH;
$foto_upload->foto_folder = IMAGES_IMAGE_PATH;
$foto_upload->thumb_folder = IMAGES_IMAGE_THUMB_PATH;
$foto_upload->extensions = array(".jpg", ".gif", ".png", ".jpeg",".pdf");
$foto_upload->language = "en";
$foto_upload->x_max_size = 100;
$foto_upload->y_max_size = 100;
$foto_upload->x_max_thumb_size = 100;
$foto_upload->y_max_thumb_size = 100;

$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 = "upload";
$nameinfile = isset($_FILES['myfile']['filename'])?$_FILES['myfile']['filename']:$_FILES['myfile']['name'];

$onlyfilename1=explode('.',$nameinfile);
 $onlyfilename = $onlyfilename1[0];
/*
if($fname !='' || $filenameid !='')
{
    $filename = "profile".'-'.$fname.'-'.$filenameid.'-'.$onlyfilename.'-'.strtotime("now");
}
elseif($fname !='' || $filenameid =='')
{
    $filename = "profile".'-'.$fname.'-'.$onlyfilename.'-'.strtotime("now");
}
elseif($fname =='' || $filenameid !='')
{
    $filename = "profile".'-'.$filenameid.'-'.$onlyfilename.'-'.strtotime("now");
}
elseif($fname =='' || $filenameid =='')
{
    $filename = "profile".'-'.$onlyfilename.'-'.strtotime("now");
}
else
{
    $filename = "profile".'-'.$onlyfilename.'-'.strtotime("now");
}*/
	$filename = "image-".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'];
?>