Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Improved function "getMaxSize" 14 Aug 2013 08:56 #10775

The function getMaxSize located in COMPONENT\classes\file\upload.php, doesn't consider the server variable upload_max_filesize.
Sometimes the component config variable "upload_maxsize" is bigger than the previous server variable, so it happens to give a wrong info to the user at the upload process. I think the server variable upload_max_filesize should be considered as well, so here my hack to do it:
	public static function getMaxSize($string = false, $maxSizeCustom = null)
	{
		$config	= JComponentHelper::getParams( 'com_component' );

		$maxSize = (int)$config->get('upload_maxsize') * 1024 * 1024;
		$phpMaxSize = intval(ini_get('upload_max_filesize')) * 1024 * 1024; /* hack */
		
		if (!$maxSize)
			$maxSize =COMPONENT_UPLOAD_DEFAULT_MAX_SIZE;
			
		if ($maxSizeCustom)
			$maxSize = min($maxSize, $maxSizeCustom);

		$maxSize = min($maxSize, $phpMaxSize); /* hack */

		if ($string)
			$maxSize = JText::sprintf("COMPONENT_UPLOAD_MAX_B", self::bytesToString($maxSize));

		return $maxSize;
	}

this also solve an unexpected script exit with no warning, I encountered during the upload of big files not allowed by the server.
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

Last edit: by Tomaselli.

Improved function "getMaxSize" 18 Aug 2013 20:01 #10810

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed.
Thank you.

K+.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.055 seconds
Great UX great performance and definitely a time saver. It only took me 10 minutes of playing around before purchasing a subscription and right now I just want to throw more money at you! I just started a new project and after just 4h I can already tell it probably saved me several days of work. I'm building a wholesale ordering system with sales rep management. I have not looked at the code yet but so far: impressive.
flip (Forum)

Get Started