-1

Hello guys I want to add a new image field in opencart2 on return product page

How can I add image field in opencart

I have done as far :

view : return_form.tpl

<div class="form-group">
            <label class="col-sm-2 control-label" for="input-comment1"><?php echo $entry_image; ?></label>
            <div class="col-sm-10">
             <input type="file" name="error_img">
            </div>
          </div>

In controller return.php in function add

if (isset($this->request->post['error_img'])) {
            $data['error_img'] = $this->request->post['error_img'];
        } else {
            $data['error_img'] = false;
        }

but when I am trying to print the value of $this->request->post['error_img'] it is returning blank

what I am missing

Rohitashv Singhal
  • 4,517
  • 13
  • 57
  • 105

1 Answers1

0

:)

you need to use $this->request->files['error_img'] instead of $this->request->post['error_img']
in Opencart you can say

$_POST == $this->request->post;
$_GET == $this->request->get;
$_FILES == $this->request->files;

and many more. Please add enctype="multipart/form-data" to your form too.

Nikhil Chaudhary
  • 478
  • 4
  • 16