View file modules/user/load_avatar.php

File size: 955B
<?
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.org.ua  *
**********************************/
import_lib('upload.class');
if(file_exists(ROOT.'/files/avatars/'.cyrlat($user['nick']).'.png')) { 
	unlink(ROOT.'/files/avatars/'. cyrlat($user['nick']) .'.png');
}
$handle = new upload($_FILES['avatar']);
  if ($handle->uploaded) {
	  $handle->allowed = array('image/*');
      $handle->file_new_name_body 	= cyrlat($user['nick']);
	  $handle->image_convert 		= 'png';
      $handle->image_resize			= true;
      $handle->image_x				= 100;
      $handle->image_y				= 120;
      $handle->process(ROOT. '/files/avatars/');
      if ($handle->processed) {
          // echo 'image resized';
          $handle->clean();
		  go('/user/avatar/');
      } else {
          // echo 'error : ' . $handle->error;
		  go('/user/avatar/');
      }
  }
?>