jeudi 13 août 2015

How to set a permission in FTP after creating a directory using PHP?

I have a problem with my code. In my code there is a part that can generate a directory in the server and when I checked the directory in the FTP the initial folder is generated but the subfolders are not and when I try to open the main folder there is a log that says:

esponse:    550 /httpdocs/ecommerce/image/catalog/sellers/826: Permission denied
Error:  Failed to retrieve directory listing

In my code I have this:

public function addUser($data) {

    $this->db->query("INSERT INTO `" . DB_PREFIX . "user` SET username = '" . $this->db->escape($data['username']) . "', shop_name = '" . $this->db->escape($data['shop_name']) . "', user_group_id = '" . (int)$data['user_group_id'] . "', salt = '" . $this->db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', image = '" . $this->db->escape($data['image']) . "', status = '" . (int)$data['status'] . "', date_added = NOW()");
    $get_customer_id = $this->db->getLastId();

    $directory = DIR_IMAGE . 'catalog/sellers/' . $get_customer_id;

    if(!file_exists($directory)) {

        mkdir($directory, 777);

        mkdir($directory . '/profile', 777);
        mkdir($directory . '/banner', 777);
        mkdir($directory . '/products', 777);

    }

}

In my localhost it is working properly but when I upload it has an error. Can you help me with this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire