2013-09-21 3 views
0

opencart의 데이터 탭에 이미지를 업로드하기 위해 맞춤 이미지 필드를 추가하고 싶습니다. 이미지가 표시되지만 저장 버튼을 클릭하면 이미지가 사라지고 이미지는 mysql 데이터베이스에도 저장되지 않습니다. 그러니 제발 도와주세요. 이미지 업로드 다음 는 I은 기존 코드를 변경 :Opencart의 데이터 탭에 맞춤 이미지 필드 추가하기

제어기/카탈로그에

/product.php을

보기/템플릿/카탈로그/product_form.tpl에서
if (isset($this->request->post['backgroundimage'])) { 
     $this->data['backgroundimage'] = $this->request->post['backgroundimage']; 
    } elseif (!empty($product_info)) { 
     $this->data['backgroundimage'] = $product_info['backgroundimage']; 
    } else { 
     $this->data['backgroundimage'] = ''; 
    } 


    $this->load->model('tool/image'); 

    if (isset($this->request->post['backgroundimage']) && file_exists(DIR_IMAGE . $this->request->post['backgroundimage'])) { 
     $this->data['thumb'] = $this->model_tool_image->resize($this->request->post['backgroundimage'], 100, 100); 
    } elseif (!empty($product_info) && $product_info['backgroundimage'] && file_exists(DIR_IMAGE . $product_info['backgroundimage'])) { 
     $this->data['thumb'] = $this->model_tool_image->resize($product_info['backgroundimage'], 100, 100); 
    } else { 
     $this->data['thumb'] = $this->model_tool_image->resize('no_image.jpg', 100, 100); 
    } 

<tr> 
       <td><?php echo $entry_backgroundimage; ?></td> 
       <td><div class="image"><img src="<?php echo $thumb2; ?>" alt="" id="thumb2" /><br /> 
        <input type="hidden" name="image2" value="<?php echo $backgroundimage; ?>" id="image2" /> 
        <a onclick="image_upload('image2', 'thumb2');"><?php echo $text_browse; ?></a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb2').attr('src', '<?php echo $no_image; ?>'); $('#image2').attr('value', '');"><?php echo $text_clear; ?></a></div></td> 
      </tr> 

모델/카탈로그/제품 .php

012 3,516,
$this->db->query("INSERT INTO " . DB_PREFIX . "product SET backgroundimage = '" . $this->db->escape($data['image2']) . "',product_id = '" . (int)$product_id . "'"); 

답변

0

대신 $this->db->escape($data['image2']) 사용이 $this->db->escape(html_entity_decode($data['image2'], ENT_QUOTES, 'UTF-8'))

관련 문제