Hello. I work with OpenCart. I have the functionality presented on the site below, it is necessary to transfer it to dir admin OpenCart. I moved: it writes to the database, and the folder with the photo for the new product does not create ... The path $target_file draws image/catalog/users/customer_1/product_339 . This code works on the site itself in the dir catalog , and there is no dir admin ...

What am I doing wrong?

  if (($this->request->server['REQUEST_METHOD'] == 'POST')) { $this->load->model('catalog/product'); // подключаем модель $this->request->post['image'] = $_FILES['image']['name']; // добавляем в POST параметр image $data['productID'] = $this->model_catalog_product->addProduct($this->request->post); /// get productID from model $target_file = "image/catalog/users/customer_" . $this->request->post['id_customer'] . "/product_" . $data['productID']; if (!file_exists($target_file)) { mkdir($target_file, 0777, true); } // указываем папку на сервере для загрузки файлов move_uploaded_file($_FILES["image"]["tmp_name"], $target_file . "/" . basename($_FILES['image']["name"]));// загружаем 1 главное фото } 

    1 answer 1

    Use DIR_IMAGE from config.php instead of image , then you are guaranteed to go to the directory you need:

     if (($this->request->server['REQUEST_METHOD'] == 'POST')) { $this->load->model('catalog/product'); // подключаем модель $this->request->post['image'] = $_FILES['image']['name']; // добавляем в POST параметр image $data['productID'] = $this->model_catalog_product->addProduct($this->request->post); /// get productID from model $target_file = DIR_IMAGE . "catalog/users/customer_" . $this->request->post['id_customer'] . "/product_" . $data['productID']; if (!file_exists($target_file)) { mkdir($target_file, 0777, true); } // указываем папку на сервере для загрузки файлов move_uploaded_file($_FILES["image"]["tmp_name"], $target_file . "/" . basename($_FILES['image']["name"]));// загружаем 1 главное фото }