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>
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
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
Let's integrate this idea. In admin/controller/tool/upload.php file,
find:
Code: Select all
public function upload() {
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;
}
Code: Select all
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 128)) {
Code: Select all
$size = getimagesize($filename);
$max_size = $this->validateSize();
if ($size && (int)$size > $max_size) {
$json['error'] = $this->language->get('error_filesize');
}
find:
Code: Select all
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
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;
}
Code: Select all
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
Code: Select all
$size = getimagesize($filename);
$max_size = $this->validateSize();
if ($size && (int)$size > $max_size) {
$json['error'] = $this->language->get('error_filesize');
}
Code: Select all
$_['error_filesize'] = 'Warning: Incorrect file size!';
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
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
straightlight wrote: ↑Sat Nov 25, 2017 1:42 amSince 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:
add above:Code: Select all
public function upload() {
Then, find: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; }
add above:Code: Select all
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 128)) {
In catalog/controller/tool/upload.php file,Code: Select all
$size = getimagesize($filename); $max_size = $this->validateSize(); if ($size && (int)$size > $max_size) { $json['error'] = $this->language->get('error_filesize'); }
find:
add below:Code: Select all
$this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); }
Then, find: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; }
add above:Code: Select all
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
Then, in your catalog/language/<your_language_code>/tool/upload.php file, at the bottom of the file, add:Code: Select all
$size = getimagesize($filename); $max_size = $this->validateSize(); if ($size && (int)$size > $max_size) { $json['error'] = $this->language->get('error_filesize'); }
If the key name error_filesize isn't there already. This should rectify the issue.Code: Select all
$_['error_filesize'] = 'Warning: Incorrect file size!';
or the whole code not in parts
straightlight wrote: ↑Sat Nov 25, 2017 1:42 amSince 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:
add above:Code: Select all
public function upload() {
Then, find: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; }
add above:Code: Select all
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 128)) {
In catalog/controller/tool/upload.php file,Code: Select all
$size = getimagesize($filename); $max_size = $this->validateSize(); if ($size && (int)$size > $max_size) { $json['error'] = $this->language->get('error_filesize'); }
find:
add below:Code: Select all
$this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); }
Then, find: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; }
add above:Code: Select all
if ((utf8_strlen($filename) < 3) || (utf8_strlen($filename) > 64)) {
Then, in your catalog/language/<your_language_code>/tool/upload.php file, at the bottom of the file, add:Code: Select all
$size = getimagesize($filename); $max_size = $this->validateSize(); if ($size && (int)$size > $max_size) { $json['error'] = $this->language->get('error_filesize'); }
If the key name error_filesize isn't there already. This should rectify the issue.Code: Select all
$_['error_filesize'] = 'Warning: Incorrect file size!';
Users browsing this forum: No registered users and 16 guests