I am creating an add-on for opencart and need to save a file from a website into the admin panel, currently I have the file contents and trying to save into a custom location but every time I run the add on I get an error that the directory doesn't exist.
Here is my code that I am using in the controller
if ($this->request->server['HTTPS']) {
$url = HTTPS_SERVER;
} else {
$url = HTTP_SERVER;
}
$file = file_get_contents('Website Link');
$FileDir = $url."upload/";
$fileName = 'products.csv';
if (!is_dir($FileDir) or !is_writable($FileDir)) {
if (!is_dir($FileDir)) {
echo "No Directory"; die();
}
if (!is_writable($FileDir)) {
echo "Unable to write"; die();
}
echo $fileDir.' - '.$url
}
the error that comes back is "No Directory" I have echoed out the URL and created a directory at that location called upload and set the permissions for this directory at 777 and still getting the error.
What am I missing?
Im using opencart Version 2.1.0.2