Post by computerbar » Fri Nov 24, 2017 1:07 am

Hey all
When I try add image to product or category the image manager won't popup anymore.?

how can i fix? it was working till now and no module etc are installed since it was working.
I have already replaced all the java script folder with default. still no joy
thanks
my header.twig
<script type="text/javascript" src="view/javascript/jquery/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="view/javascript/bootstrap/js/bootstrap.min.js"></script>
<link href="view/stylesheet/bootstrap.css" type="text/css" rel="stylesheet" />
<link href="view/javascript/font-awesome/css/font-awesome.min.css" type="text/css" rel="stylesheet" />
<script src="view/javascript/jquery/datetimepicker/moment/moment.min.js" type="text/javascript"></script>
<script src="view/javascript/jquery/datetimepicker/moment/moment-with-locales.min.js" type="text/javascript"></script>
<script src="view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js" type="text/javascript"></script>

New member

Posts

Joined
Sun Jul 10, 2011 10:34 am

Post by straightlight » Fri Nov 24, 2017 2:17 am

Since you replaced all the javascript folder, ensure the folder permissions are recursively set to 0755 on your file server and that those files being re-uploaded through your host file manager console, not over FTP.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by computerbar » Sat Nov 25, 2017 1:21 am

thanks found the problem now.

If there are files bigger than 3mb the image manger won't load. I have removed the images now once again I uploaded a 4MB test file the manger won't popup again.

How can fix it for good.
1- warn user of uploaded file size.

thanks

New member

Posts

Joined
Sun Jul 10, 2011 10:34 am

Post by straightlight » Sat Nov 25, 2017 1:42 am

Since these topics begins to evolve more and more, an interesting concept I discovered on: https://stackoverflow.com/questions/130 ... pload-size is the validation of the file size and useful for each servers.

Let's integrate this idea. In admin/controller/tool/upload.php file,

find:

Code: Select all

public function upload() {
add above:

Code: Select all

protected function validateSize() {
		$max_size = -1;

		$files = array_merge(array(php_ini_loaded_file()), explode(",\n", php_ini_scanned_files()));

		foreach (array_filter($files) as $file) {
			$ini = parse_ini_file($file);
		  
			$regex = '/^([0-9]+)([bkmgtpezy])$/i';
		  
			if (!empty($ini['post_max_size']) && preg_match($regex, $ini['post_max_size'], $match)) {
				$post_max_size = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($post_max_size > 0) {
					$max_size = $post_max_size;
				}
			}
		  
			if (!empty($ini['upload_max_filesize']) && preg_match($regex, $ini['upload_max_filesize'], $match)) {
				$upload_max_filesize = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($upload_max_filesize > 0 && ($max_size <= 0 || $max_size > $upload_max_filesize)) {
					$max_size = $upload_max_filesize;
				}
			}
		}

		return (int)$max_size;
	}
Then, find:

Code: Select all

if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 128)) {
add above:

Code: Select all

$size = getimagesize($filename);

$max_size = $this->validateSize();
				
				if ($size && (int)$size > $max_size) {
					$json['error'] = $this->language->get('error_filesize');
				}
In catalog/controller/tool/upload.php file,

find:

Code: Select all

$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
add below:

Code: Select all

protected function validateSize() {
		$max_size = -1;

		$files = array_merge(array(php_ini_loaded_file()), explode(",\n", php_ini_scanned_files()));

		foreach (array_filter($files) as $file) {
			$ini = parse_ini_file($file);
		  
			$regex = '/^([0-9]+)([bkmgtpezy])$/i';
		  
			if (!empty($ini['post_max_size']) && preg_match($regex, $ini['post_max_size'], $match)) {
				$post_max_size = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($post_max_size > 0) {
					$max_size = $post_max_size;
				}
			}
		  
			if (!empty($ini['upload_max_filesize']) && preg_match($regex, $ini['upload_max_filesize'], $match)) {
				$upload_max_filesize = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($upload_max_filesize > 0 && ($max_size <= 0 || $max_size > $upload_max_filesize)) {
					$max_size = $upload_max_filesize;
				}
			}
		}

		return (int)$max_size;
	}
Then, find:

Code: Select all

if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
add above:

Code: Select all

$size = getimagesize($filename);

$max_size = $this->validateSize();
				
				if ($size && (int)$size > $max_size) {
					$json['error'] = $this->language->get('error_filesize');
				}
Then, in your catalog/language/<your_language_code>/tool/upload.php file, at the bottom of the file, add:

Code: Select all

$_['error_filesize']   = 'Warning: Incorrect file size!';
If the key name error_filesize isn't there already. This should rectify the issue.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Sat Nov 25, 2017 1:44 am

Post updated above. Take note that these modifications will only work if the basedir and safe-mode are NOT enabled.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by bluebrad » Fri Oct 11, 2019 1:04 am

Couldn't you just provide the corrected file?


straightlight wrote:
Sat Nov 25, 2017 1:42 am
Since these topics begins to evolve more and more, an interesting concept I discovered on: https://stackoverflow.com/questions/130 ... pload-size is the validation of the file size and useful for each servers.

Let's integrate this idea. In admin/controller/tool/upload.php file,

find:

Code: Select all

public function upload() {
add above:

Code: Select all

protected function validateSize() {
		$max_size = -1;

		$files = array_merge(array(php_ini_loaded_file()), explode(",\n", php_ini_scanned_files()));

		foreach (array_filter($files) as $file) {
			$ini = parse_ini_file($file);
		  
			$regex = '/^([0-9]+)([bkmgtpezy])$/i';
		  
			if (!empty($ini['post_max_size']) && preg_match($regex, $ini['post_max_size'], $match)) {
				$post_max_size = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($post_max_size > 0) {
					$max_size = $post_max_size;
				}
			}
		  
			if (!empty($ini['upload_max_filesize']) && preg_match($regex, $ini['upload_max_filesize'], $match)) {
				$upload_max_filesize = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($upload_max_filesize > 0 && ($max_size <= 0 || $max_size > $upload_max_filesize)) {
					$max_size = $upload_max_filesize;
				}
			}
		}

		return (int)$max_size;
	}
Then, find:

Code: Select all

if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 128)) {
add above:

Code: Select all

$size = getimagesize($filename);

$max_size = $this->validateSize();
				
				if ($size && (int)$size > $max_size) {
					$json['error'] = $this->language->get('error_filesize');
				}
In catalog/controller/tool/upload.php file,

find:

Code: Select all

$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
add below:

Code: Select all

protected function validateSize() {
		$max_size = -1;

		$files = array_merge(array(php_ini_loaded_file()), explode(",\n", php_ini_scanned_files()));

		foreach (array_filter($files) as $file) {
			$ini = parse_ini_file($file);
		  
			$regex = '/^([0-9]+)([bkmgtpezy])$/i';
		  
			if (!empty($ini['post_max_size']) && preg_match($regex, $ini['post_max_size'], $match)) {
				$post_max_size = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($post_max_size > 0) {
					$max_size = $post_max_size;
				}
			}
		  
			if (!empty($ini['upload_max_filesize']) && preg_match($regex, $ini['upload_max_filesize'], $match)) {
				$upload_max_filesize = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($upload_max_filesize > 0 && ($max_size <= 0 || $max_size > $upload_max_filesize)) {
					$max_size = $upload_max_filesize;
				}
			}
		}

		return (int)$max_size;
	}
Then, find:

Code: Select all

if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
add above:

Code: Select all

$size = getimagesize($filename);

$max_size = $this->validateSize();
				
				if ($size && (int)$size > $max_size) {
					$json['error'] = $this->language->get('error_filesize');
				}
Then, in your catalog/language/<your_language_code>/tool/upload.php file, at the bottom of the file, add:

Code: Select all

$_['error_filesize']   = 'Warning: Incorrect file size!';
If the key name error_filesize isn't there already. This should rectify the issue.

Newbie

Posts

Joined
Tue Dec 05, 2017 2:49 pm

Post by bluebrad » Fri Oct 11, 2019 6:26 am

can you provide the file that is fixed?
or the whole code not in parts
straightlight wrote:
Sat Nov 25, 2017 1:42 am
Since these topics begins to evolve more and more, an interesting concept I discovered on: https://stackoverflow.com/questions/130 ... pload-size is the validation of the file size and useful for each servers.

Let's integrate this idea. In admin/controller/tool/upload.php file,

find:

Code: Select all

public function upload() {
add above:

Code: Select all

protected function validateSize() {
		$max_size = -1;

		$files = array_merge(array(php_ini_loaded_file()), explode(",\n", php_ini_scanned_files()));

		foreach (array_filter($files) as $file) {
			$ini = parse_ini_file($file);
		  
			$regex = '/^([0-9]+)([bkmgtpezy])$/i';
		  
			if (!empty($ini['post_max_size']) && preg_match($regex, $ini['post_max_size'], $match)) {
				$post_max_size = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($post_max_size > 0) {
					$max_size = $post_max_size;
				}
			}
		  
			if (!empty($ini['upload_max_filesize']) && preg_match($regex, $ini['upload_max_filesize'], $match)) {
				$upload_max_filesize = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($upload_max_filesize > 0 && ($max_size <= 0 || $max_size > $upload_max_filesize)) {
					$max_size = $upload_max_filesize;
				}
			}
		}

		return (int)$max_size;
	}
Then, find:

Code: Select all

if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 128)) {
add above:

Code: Select all

$size = getimagesize($filename);

$max_size = $this->validateSize();
				
				if ($size && (int)$size > $max_size) {
					$json['error'] = $this->language->get('error_filesize');
				}
In catalog/controller/tool/upload.php file,

find:

Code: Select all

$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
add below:

Code: Select all

protected function validateSize() {
		$max_size = -1;

		$files = array_merge(array(php_ini_loaded_file()), explode(",\n", php_ini_scanned_files()));

		foreach (array_filter($files) as $file) {
			$ini = parse_ini_file($file);
		  
			$regex = '/^([0-9]+)([bkmgtpezy])$/i';
		  
			if (!empty($ini['post_max_size']) && preg_match($regex, $ini['post_max_size'], $match)) {
				$post_max_size = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($post_max_size > 0) {
					$max_size = $post_max_size;
				}
			}
		  
			if (!empty($ini['upload_max_filesize']) && preg_match($regex, $ini['upload_max_filesize'], $match)) {
				$upload_max_filesize = round($match[1] * pow(1024, stripos('bkmgtpezy', strtolower($match[2]))));
			
				if ($upload_max_filesize > 0 && ($max_size <= 0 || $max_size > $upload_max_filesize)) {
					$max_size = $upload_max_filesize;
				}
			}
		}

		return (int)$max_size;
	}
Then, find:

Code: Select all

if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
add above:

Code: Select all

$size = getimagesize($filename);

$max_size = $this->validateSize();
				
				if ($size && (int)$size > $max_size) {
					$json['error'] = $this->language->get('error_filesize');
				}
Then, in your catalog/language/<your_language_code>/tool/upload.php file, at the bottom of the file, add:

Code: Select all

$_['error_filesize']   = 'Warning: Incorrect file size!';
If the key name error_filesize isn't there already. This should rectify the issue.

Newbie

Posts

Joined
Tue Dec 05, 2017 2:49 pm
Who is online

Users browsing this forum: No registered users and 16 guests