How to solve OpenCart 2 issue when FTP support is disabled?
OpenCart 2.0 is out and there are a couple of things that need a little help to work as intended. For instance If you get an error below saying "Could not connect as ......" while uploading your zipped extensions via the Extension Installer, you probably have the FTP support disabled from your hosting. We will offer two ways to solve this - one for tech-savvy people who are comfortable with editing files on their FTP and one for store owners who can run it via the OC Installer.
1. Here is how to fix this? (Developer version)
Open up Notepad++, Dreaweaver or any other editor and go to admin/controller/extension/installer.php and before the line saying:
public function unzip() {
paste the following code
public function localcopy() { $this->load->language('extension/installer'); $json = array(); if (!$this->user->hasPermission('modify', 'extension/installer')) { $json['error'] = $this->language->get('error_permission'); } $directory = DIR_DOWNLOAD . str_replace(array('../', '..\\', '..'), '', $this->request->post['path']) . '/upload/'; if (!is_dir($directory)) { $json['error'] = $this->language->get('error_directory'); } if (!$json) { // Get a list of files ready to upload $files = array(); $path = array($directory . '*'); while (count($path) != 0) { $next = array_shift($path); foreach (glob($next) as $file) { if (is_dir($file)) { $path[] = $file . '/*'; } $files[] = $file; } } $root = dirname(DIR_APPLICATION).'/'; foreach ($files as $file) { // Upload everything in the upload directory $destination = $root.substr($file, strlen($directory)); if (is_dir($file)) { $list = glob(rtrim($destination, '/').'/*'); if (!file_exists($destination)) { if (!mkdir($destination)) { $json['error'] = sprintf($this->language->get('error_ftp_directory'), $destination); } } } if (is_file($file)) { if (!copy($file, $destination)) { $json['error'] = sprintf($this->language->get('error_ftp_file'), $file); } } } } $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput(json_encode($json)); }
Then find this line:
'url' => str_replace('&', '&', $this->url->link('extension/installer/ftp', 'token=' . $this->session->data['token'], 'SSL')),
and change it with:
'url' => str_replace('&', '&', $this->url->link('extension/installer/localcopy', 'token=' . $this->session->data['token'], 'SSL')),
2. Here is how to fix this? (Store owner version, set up in less than 30 seconds)
As an alternative you can just download this OCMOD ready modification file, which we contributed to the OpenCart society and just follow the installation instructions : http://www.opencart.com/index.php?route=extension/extension/info&extension_id=18892
That's it, you can now enjoy the module installer! Sharing is caring so spread the word. Thanks!