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.071 seconds

Amazing Tool !
And only tool I know that allows complete Scaffolding in terms of component creation. It really saves loads of time (actually much more than that). Simple architecture enables quick and painless changes at any time. Code is clean and consintent. It's just... what's the word... neat! :) Great work! You should definetely try this one!

pi_wo (JED)
         

Get Started