Can't install ocmods trough the opencart extension installer

Posted by Flo on 20 May 2016

So far this was never an issue, there were problems with uploading modules via the installer because of the ftp connection but you could allways install ocmods without any issue.

However, some automated cpanel installers instead of solving the previous issues they created on opencart installations, now they add even more.

If you are trying to upload .ocmod.xml files via the extension installer and you get an error like this one:

SyntaxError: Unexpected token < in JSON at position 0

Warning: mkdir(): No such file or directory in ../admin/controller/extension/installer.php on line 82 Warning: move_uploaded_file(../install.xml): failed to open stream: No such file or directory in ../admin/controller/extension/installer.php on line 93 Warning: move_uploaded_file(): Unable to move '...tmp' to '../system/upload/temp-long-code/install.xml' in ../admin/controller/extension/installer.php on line 93{"step":[],"overwrite":[],"error":"File could not be found!"}

You need to check your config files because they are most likely missconfigured

You may notice in the above error the path ../system/upload/temp-long-code/install.xml. But system/upload is not the real path of the upload folder in opencart 2.1+, it is actually system/storage/upload. So the config files are missing a folder from the path and that creates the issue.

To solve it, you need to  edit the admin/config.php and the root config.php files.

Once you open the files you might notice that not only the DIR_UPLOAD contant is incorrect but DIR_CACHE, DIR_DOWNLOAD, DIR_LOGS and DIR_MODIFICATION as well.

Their values is made by concatenating the DIR_SYSTEM value with their folder name:

define('DIR_UPLOAD', DIR_SYSTEM . 'upload/');

And you need to add the storage folder before the actual folder name, like this:

define('DIR_UPLOAD', DIR_SYSTEM . 'storage/upload/');

Dont forget that you need to do this for the other constants mentioned above as well, and in both the admin config.php and the root one.

After you corrected the mistakes, save the files and you should be ok. While you're at it make sure the root config.php doesnt have a DIR_CATALOG constant in it, you can read more about that issue in the below article.