<?php

include_once("class.upload.php");


//upload image take folder path , height, width
function uploadImages($handle, $url, $width, $height)
	{
		if ($handle->uploaded) 
		{
			$randomname =md5( uniqid(mt_rand(),true));
			$handle->image_resize         = true;
			$handle->image_x              = $width;
			$handle->image_y              = $height;
			$handle->image_ratio_y        = false;
			$handle->file_new_name_body = $randomname;
			$handle->process($url);
			if ($handle->processed)
			{
				$handle->clean();
			}
			else
			{
				echo 'error : ' . $handle->error;
			}
		}
		$full = $randomname.".".$handle->file_src_name_ext;
		return $full;
	}

function uploadImages2($handle, $url) {
    if ($handle->uploaded) {
        $randomname = md5(uniqid(mt_rand(), true));
        $handle->image_resize = true;
        //$handle->image_x              = $width;
        //$handle->image_y              = $height;
        $handle->image_ratio_y = false;
        $handle->file_new_name_body = $randomname;
        $handle->process($url);
        if ($handle->processed) {
            $handle->clean();
        } else {
            echo 'error : ' . $handle->error;
        }
    }
    $full = $randomname . "." . $handle->file_src_name_ext;
    return $full;
}

function updateImages($handle, $hiddenFileName, $url, $width, $height)
	{
		   //uploadfile
		$randomname="new";
		if ($handle->uploaded) {
			$randomname =md5( uniqid(mt_rand(),true));
			$handle->image_resize         = true;
			$handle->image_x              = $width;
			$handle->image_y              = $height;
			$handle->image_ratio_y        = false;
			$handle->file_new_name_body = $randomname;
			$handle->process($url);
			if ($handle->processed)
			 {
				$handle->clean();
			 } 
			 else
			 {               
				echo 'error : ' . $handle->error;
			 }
		}
		if($randomname =="new")
		{
			$full =$_POST[''.$hiddenFileName.''];
		}
		else
		{
		   $full = $randomname.".".$handle->file_src_name_ext;
		}
		return $full;
	}


function uploadfile($handle, $url)
	{
		if ($handle->uploaded) 
		{
			$randomname =md5( uniqid(mt_rand(),true));
			$handle->file_new_name_body = $randomname;
			$handle->process($url);
			if ($handle->processed)
			{
				$handle->clean();
			}
			else
			{
				echo 'error : ' . $handle->error;
			}
		}
		$full = $randomname.".".$handle->file_src_name_ext;
		return $full;
	}
	
	
	
	function updatefile($handle, $hiddenFileName, $url)
	{
		   //uploadfile
		$randomname="new";
		if ($handle->uploaded) {
			$randomname =md5( uniqid(mt_rand(),true));
		
			$handle->file_new_name_body = $randomname;
			$handle->process($url);
			if ($handle->processed)
			 {
				$handle->clean();
			 } 
			 else
			 {               
				echo 'error : ' . $handle->error;
			 }
		}
		if($randomname =="new")
		{
			$full =$_POST[''.$hiddenFileName.''];
		}
		else
		{
		   $full = $randomname.".".$handle->file_src_name_ext;
		}
		return $full;
	}
	
	
	
	function updateImagesWithoutHeaight($handle, $hiddenFileName, $url, $width)
	{
		   //uploadfile
		$randomname="new";
		if ($handle->uploaded) {
			$randomname =md5( uniqid(mt_rand(),true));
			$handle->image_resize         = true;
			$handle->image_x              = $width;
			//$handle->image_y              = $height;
			$handle->image_ratio_y        = true;
			$handle->file_new_name_body = $randomname;
			$handle->process($url);
			if ($handle->processed)
			 {
				$handle->clean();
			 } 
			 else
			 {               
				echo 'error : ' . $handle->error;
			 }
		}
		if($randomname =="new")
		{
			$full =$_POST[''.$hiddenFileName.''];
		}
		else
		{
		   $full = $randomname.".".$handle->file_src_name_ext;
		}
		return $full;
	}
        
        
        
        
   function uploadImageswhioutresize($handle, $url) {
       
       print_r("ddddddddddddddddddddddddddd");
    if ($handle->uploaded) {
        $randomname = md5(uniqid(mt_rand(), true));
        $handle->image_resize = false;
        /* $handle->image_x              = $width;
          $handle->image_y              = $height;
          $handle->image_ratio_y        = false; */
        $handle->file_new_name_body = $randomname;
        $handle->process($url);
        if ($handle->processed) {
            $handle->clean();
        } else {
            echo 'error : ' . $handle->error;
        }
    }
    $full = $randomname . "." . $handle->file_src_name_ext;
    return $full;
}
        
    function updateImagesWithoutresiz($handle, $hiddenFileName, $url) {
    //uploadfile
    $randomname = "new";
    if ($handle->uploaded) {
        $randomname = md5(uniqid(mt_rand(), true));
        $handle->image_resize = false;
        //$handle->image_x              = $width;
        //$handle->image_y              = $height;
        $handle->image_ratio_y = true;
        $handle->file_new_name_body = $randomname;
        $handle->process($url);
        if ($handle->processed) {
            $handle->clean();
        } else {
            echo 'error : ' . $handle->error;
        }
    }
    if ($randomname == "new") {
        $full = $_POST['' . $hiddenFileName . ''];
    } else {
        $full = $randomname . "." . $handle->file_src_name_ext;
    }
    return $full;
}


?>