OPENCART 2.0 IMAGE MANAGER NOT WORKING <p><strong>IF NOT WORKING THEN CHANGE THE CODE IN FOLLOWING : Admin /conroller / common / filemanager.php</strong></p> <p>BY VINAY SINGH [ vinaysingh43@gmail.com] skype : vinaysingh43</p> <p>or Chagne the Code in line no GLOBAL_BRACE </p> <p>CONSTANT this contstant not wroking wth some server ... </p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php class ControllerCommonFileManager extends Controller { public function index() { $this-&gt;load-&gt;language('common/filemanager'); if (isset($this-&gt;request-&gt;get['filter_name'])) { $filter_name = rtrim(str_replace(array('../', '..\\', '..', '*'), '', $this-&gt;request-&gt;get['filter_name']), '/'); } else { $filter_name = null; } // Make sure we have the correct directory if (isset($this-&gt;request-&gt;get['directory'])) { $directory = rtrim(DIR_IMAGE . 'catalog/' . str_replace(array('../', '..\\', '..'), '', $this-&gt;request-&gt;get['directory']), '/'); } else { $directory = DIR_IMAGE . 'catalog'; } if (isset($this-&gt;request-&gt;get['page'])) { $page = $this-&gt;request-&gt;get['page']; } else { $page = 1; } $data['images'] = array(); $this-&gt;load-&gt;model('tool/image'); // Get directories $directories = glob($directory . '/' . $filter_name . '*', GLOB_ONLYDIR); if (!$directories) { $directories = array(); } // Get files // $files = glob($directory . '/' . $filter_name . '*.{jpg,jpeg,png,gif,JPG,JPEG,PNG,GIF}', GLOB_BRACE); $files1 = glob($directory . '/' . $filter_name . '*.jpg'); if (!$files1) { $files1 = array(); } $files2 = glob($directory . '/' . $filter_name . '*.jpeg'); if (!$files2) { $files2 = array(); } $files3 = glob($directory . '/' . $filter_name . '*.JPG'); if (!$files3) { $files3 = array(); } $files4 = glob($directory . '/' . $filter_name . '*.png'); if (!$files4) { $files4 = array(); } $files5 = glob($directory . '/' . $filter_name . '*.JPEG'); if (!$files5) { $files5 = array(); } $files6 = glob($directory . '/' . $filter_name . '*.PNG'); if (!$files6) { $files6 = array(); } $files7 = glob($directory . '/' . $filter_name . '*.GIF'); if (!$files7) { $files7 = array(); } $files8 = glob($directory . '/' . $filter_name . '*.gif'); if (!$files8) { $files8 = array(); } $files = array_merge($files1, $files2,$files3,$files4,$files5,$files6,$files7,$files8); // Merge directories and files $images = array_merge($directories, $files); // Get total number of files and directories $image_total = count($images); // Split the array based on current page number and max number of items per page of 10 $images = array_splice($images, ($page - 1) * 16, 16); foreach ($images as $image) { $name = str_split(basename($image), 14); if (is_dir($image)) { $url = ''; if (isset($this-&gt;request-&gt;get['target'])) { $url .= '&amp;target=' . $this-&gt;request-&gt;get['target']; } if (isset($this-&gt;request-&gt;get['thumb'])) { $url .= '&amp;thumb=' . $this-&gt;request-&gt;get['thumb']; } $data['images'][] = array( 'thumb' =&gt; '', 'name' =&gt; implode(' ', $name), 'type' =&gt; 'directory', 'path' =&gt; utf8_substr($image, utf8_strlen(DIR_IMAGE)), 'href' =&gt; $this-&gt;url-&gt;link('common/filemanager', 'token=' . $this-&gt;session-&gt;data['token'] . '&amp;directory=' . urlencode(utf8_substr($image, utf8_strlen(DIR_IMAGE . 'catalog/'))) . $url, true) ); } elseif (is_file($image)) { // Find which protocol to use to pass the full image link back if ($this-&gt;request-&gt;server['HTTPS']) { $server = HTTPS_CATALOG; } else { $server = HTTP_CATALOG; } $data['images'][] = array( 'thumb' =&gt; $this-&gt;model_tool_image-&gt;resize(utf8_substr($image, utf8_strlen(DIR_IMAGE)), 100, 100), 'name' =&gt; implode(' ', $name), 'type' =&gt; 'image', 'path' =&gt; utf8_substr($image, utf8_strlen(DIR_IMAGE)), 'href' =&gt; $server . 'image/' . utf8_substr($image, utf8_strlen(DIR_IMAGE)) ); } } $data['heading_title'] = $this-&gt;language-&gt;get('heading_title'); $data['text_no_results'] = $this-&gt;language-&gt;get('text_no_results'); $data['text_confirm'] = $this-&gt;language-&gt;get('text_confirm'); $data['entry_search'] = $this-&gt;language-&gt;get('entry_search'); $data['entry_folder'] = $this-&gt;language-&gt;get('entry_folder'); $data['button_parent'] = $this-&gt;language-&gt;get('button_parent'); $data['button_refresh'] = $this-&gt;language-&gt;get('button_refresh'); $data['button_upload'] = $this-&gt;language-&gt;get('button_upload'); $data['button_folder'] = $this-&gt;language-&gt;get('button_folder'); $data['button_delete'] = $this-&gt;language-&gt;get('button_delete'); $data['button_search'] = $this-&gt;language-&gt;get('button_search'); $data['token'] = $this-&gt;session-&gt;data['token']; if (isset($this-&gt;request-&gt;get['directory'])) { $data['directory'] = urlencode($this-&gt;request-&gt;get['directory']); } else { $data['directory'] = ''; } if (isset($this-&gt;request-&gt;get['filter_name'])) { $data['filter_name'] = $this-&gt;request-&gt;get['filter_name']; } else { $data['filter_name'] = ''; } // Return the target ID for the file manager to set the value if (isset($this-&gt;request-&gt;get['target'])) { $data['target'] = $this-&gt;request-&gt;get['target']; } else { $data['target'] = ''; } // Return the thumbnail for the file manager to show a thumbnail if (isset($this-&gt;request-&gt;get['thumb'])) { $data['thumb'] = $this-&gt;request-&gt;get['thumb']; } else { $data['thumb'] = ''; } // Parent $url = ''; if (isset($this-&gt;request-&gt;get['directory'])) { $pos = strrpos($this-&gt;request-&gt;get['directory'], '/'); if ($pos) { $url .= '&amp;directory=' . urlencode(substr($this-&gt;request-&gt;get['directory'], 0, $pos)); } } if (isset($this-&gt;request-&gt;get['target'])) { $url .= '&amp;target=' . $this-&gt;request-&gt;get['target']; } if (isset($this-&gt;request-&gt;get['thumb'])) { $url .= '&amp;thumb=' . $this-&gt;request-&gt;get['thumb']; } $data['parent'] = $this-&gt;url-&gt;link('common/filemanager', 'token=' . $this-&gt;session-&gt;data['token'] . $url, true); // Refresh $url = ''; if (isset($this-&gt;request-&gt;get['directory'])) { $url .= '&amp;directory=' . urlencode($this-&gt;request-&gt;get['directory']); } if (isset($this-&gt;request-&gt;get['target'])) { $url .= '&amp;target=' . $this-&gt;request-&gt;get['target']; } if (isset($this-&gt;request-&gt;get['thumb'])) { $url .= '&amp;thumb=' . $this-&gt;request-&gt;get['thumb']; } $data['refresh'] = $this-&gt;url-&gt;link('common/filemanager', 'token=' . $this-&gt;session-&gt;data['token'] . $url, true); $url = ''; if (isset($this-&gt;request-&gt;get['directory'])) { $url .= '&amp;directory=' . urlencode(html_entity_decode($this-&gt;request-&gt;get['directory'], ENT_QUOTES, 'UTF-8')); } if (isset($this-&gt;request-&gt;get['filter_name'])) { $url .= '&amp;filter_name=' . urlencode(html_entity_decode($this-&gt;request-&gt;get['filter_name'], ENT_QUOTES, 'UTF-8')); } if (isset($this-&gt;request-&gt;get['target'])) { $url .= '&amp;target=' . $this-&gt;request-&gt;get['target']; } if (isset($this-&gt;request-&gt;get['thumb'])) { $url .= '&amp;thumb=' . $this-&gt;request-&gt;get['thumb']; } $pagination = new Pagination(); $pagination-&gt;total = $image_total; $pagination-&gt;page = $page; $pagination-&gt;limit = 16; $pagination-&gt;url = $this-&gt;url-&gt;link('common/filemanager', 'token=' . $this-&gt;session-&gt;data['token'] . $url . '&amp;page={page}', true); $data['pagination'] = $pagination-&gt;render(); $this-&gt;response-&gt;setOutput($this-&gt;load-&gt;view('common/filemanager', $data)); } public function upload() { $this-&gt;load-&gt;language('common/filemanager'); $json = array(); // Check user has permission if (!$this-&gt;user-&gt;hasPermission('modify', 'common/filemanager')) { $json['error'] = $this-&gt;language-&gt;get('error_permission'); } // Make sure we have the correct directory if (isset($this-&gt;request-&gt;get['directory'])) { $directory = rtrim(DIR_IMAGE . 'catalog/' . str_replace(array('../', '..\\', '..'), '', $this-&gt;request-&gt;get['directory']), '/'); } else { $directory = DIR_IMAGE . 'catalog'; } // Check its a directory if (!is_dir($directory)) { $json['error'] = $this-&gt;language-&gt;get('error_directory'); } if (!$json) { if (!empty($this-&gt;request-&gt;files['file']['name']) &amp;&amp; is_file($this-&gt;request-&gt;files['file']['tmp_name'])) { // Sanitize the filename $filename = basename(html_entity_decode($this-&gt;request-&gt;files['file']['name'], ENT_QUOTES, 'UTF-8')); // Validate the filename length if ((utf8_strlen($filename) &lt; 3) || (utf8_strlen($filename) &gt; 255)) { $json['error'] = $this-&gt;language-&gt;get('error_filename'); } // Allowed file extension types $allowed = array( 'jpg', 'jpeg', 'gif', 'png' ); if (!in_array(utf8_strtolower(utf8_substr(strrchr($filename, '.'), 1)), $allowed)) { $json['error'] = $this-&gt;language-&gt;get('error_filetype'); } // Allowed file mime types $allowed = array( 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif' ); if (!in_array($this-&gt;request-&gt;files['file']['type'], $allowed)) { $json['error'] = $this-&gt;language-&gt;get('error_filetype'); } // Return any upload error if ($this-&gt;request-&gt;files['file']['error'] != UPLOAD_ERR_OK) { $json['error'] = $this-&gt;language-&gt;get('error_upload_' . $this-&gt;request-&gt;files['file']['error']); } } else { $json['error'] = $this-&gt;language-&gt;get('error_upload'); } } if (!$json) { move_uploaded_file($this-&gt;request-&gt;files['file']['tmp_name'], $directory . '/' . $filename); $json['success'] = $this-&gt;language-&gt;get('text_uploaded'); } $this-&gt;response-&gt;addHeader('Content-Type: application/json'); $this-&gt;response-&gt;setOutput(json_encode($json)); } public function folder() { $this-&gt;load-&gt;language('common/filemanager'); $json = array(); // Check user has permission if (!$this-&gt;user-&gt;hasPermission('modify', 'common/filemanager')) { $json['error'] = $this-&gt;language-&gt;get('error_permission'); } // Make sure we have the correct directory if (isset($this-&gt;request-&gt;get['directory'])) { $directory = rtrim(DIR_IMAGE . 'catalog/' . str_replace(array('../', '..\\', '..'), '', $this-&gt;request-&gt;get['directory']), '/'); } else { $directory = DIR_IMAGE . 'catalog'; } // Check its a directory if (!is_dir($directory)) { $json['error'] = $this-&gt;language-&gt;get('error_directory'); } if (!$json) { // Sanitize the folder name $folder = str_replace(array('../', '..\\', '..'), '', basename(html_entity_decode($this-&gt;request-&gt;post['folder'], ENT_QUOTES, 'UTF-8'))); // Validate the filename length if ((utf8_strlen($folder) &lt; 3) || (utf8_strlen($folder) &gt; 128)) { $json['error'] = $this-&gt;language-&gt;get('error_folder'); } // Check if directory already exists or not if (is_dir($directory . '/' . $folder)) { $json['error'] = $this-&gt;language-&gt;get('error_exists'); } } if (!$json) { mkdir($directory . '/' . $folder, 0777); chmod($directory . '/' . $folder, 0777); $json['success'] = $this-&gt;language-&gt;get('text_directory'); } $this-&gt;response-&gt;addHeader('Content-Type: application/json'); $this-&gt;response-&gt;setOutput(json_encode($json)); } public function delete() { $this-&gt;load-&gt;language('common/filemanager'); $json = array(); // Check user has permission if (!$this-&gt;user-&gt;hasPermission('modify', 'common/filemanager')) { $json['error'] = $this-&gt;language-&gt;get('error_permission'); } if (isset($this-&gt;request-&gt;post['path'])) { $paths = $this-&gt;request-&gt;post['path']; } else { $paths = array(); } // Loop through each path to run validations foreach ($paths as $path) { $path = rtrim(DIR_IMAGE . str_replace(array('../', '..\\', '..'), '', $path), '/'); // Check path exsists if ($path == DIR_IMAGE . 'catalog') { $json['error'] = $this-&gt;language-&gt;get('error_delete'); break; } } if (!$json) { // Loop through each path foreach ($paths as $path) { $path = rtrim(DIR_IMAGE . str_replace(array('../', '..\\', '..'), '', $path), '/'); // If path is just a file delete it if (is_file($path)) { unlink($path); // If path is a directory beging deleting each file and sub folder } elseif (is_dir($path)) { $files = array(); // Make path into an array $path = array($path . '*'); // While the path array is still populated keep looping through while (count($path) != 0) { $next = array_shift($path); foreach (glob($next) as $file) { // If directory add to path array if (is_dir($file)) { $path[] = $file . '/*'; } // Add the file to the files to be deleted array $files[] = $file; } } // Reverse sort the file array rsort($files); foreach ($files as $file) { // If file just delete if (is_file($file)) { unlink($file); // If directory use the remove directory function } elseif (is_dir($file)) { rmdir($file); } } } } $json['success'] = $this-&gt;language-&gt;get('text_delete'); } $this-&gt;response-&gt;addHeader('Content-Type: application/json'); $this-&gt;response-&gt;setOutput(json_encode($json)); } }</code></pre> </div> </div> </p>