Jump to content

Add field Image to form


ChOmar
 Share

Recommended Posts

i add input like that 

 

  array(
                'type' => 'file',
                'label' => $this->l('Logo or photo'),
                'name' => 'sellerImage',
                'image' => $image_url?$image_url:'No Image',
                'size' => $image_size?$image_size:' : No size for Image',
                'display_image' => true,
                'col' => 6,
             ),

 

and this for add Image to folder
 

public function renderForm()
    {
        /** @var Customer $obj */
                $image_url = false;
        $image_size = 0;
        $customer = new Customer((int)Tools::getValue('id_customer'));
            $image = PS_IMG_DIR . 'sellers/' .$customer->id_customer . '.jpg';
            
            $image_url = ImageManager::thumbnail($image, (int)$customer->id_customer.'.jpg',200, 'jpg', true, true);
            $image_size = file_exists($image) ? filesize($image) / 1000 : false;
 

 

 public function postProcess()
    {
        if (!$this->can_add_customer && $this->display == 'add') {
            $this->redirect_after = $this->context->link->getAdminLink('AdminCustomers');
        }
 if ($_FILES['sellerImage']['name'] != "") {
                if (!Seller::saveSellerImage($_FILES['sellerImage'], $id_customer)) {
                    $this->errors[] = $this->module->l('The image seller format is incorrect.', 'AdminSellersController');
                }
            }
        parent::postProcess();
    }

 

and that's not working for me please help

 

AdminCustomersController.php

Edited by ChOmar
update (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More