Ecshop商品新增加一个图片上传功能

转载 2016年05月31日 22:05:23

ecshop商品新增加一个图片上传功能

 

数据库修改

goods表中增加字段

tuijie_img varchar(255)

ALTER TABLE `tlxj_goods` ADD `tuijie_img` VARCHAR( 255 ) NOT NULL

 

/admin/templates/goods_info.htm中增加代码

<tr>

            <td class="label">上传商品推介图片:</td>

            <td>

              <input type="file" name="tuijie_img" size="35" />

              {if $goods.tuijie_img}

                <a href="goods.php?act=show_image&img_url={$goods.tuijie_img}" target="_blank"><img src="images/yes.gif" border="0" /></a>

              {else}

                <img src="images/no.gif" />

              {/if}

            </td>

          </tr> 

/admin/goods.php

在代码

$goods_thumb = (empty($goods_thumb) && isset($_POST['auto_thumb']))? $goods_img : $goods_thumb;

后面增加代码

 

//$tuijie_img_name = basename($image->upload_image($_FILES['tuijie_img'],'tuijie_img'));

//$tuijie_img = '/data/tuijie_img/'. $tuijie_img_name;

$tuijie_img = $image->upload_image($_FILES['tuijie_img']);

 

把代码

 

    if ($is_insert)

    {

        if ($code == '')

        {

            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .

                    "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .

                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .

                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .

                    "is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id, danweijiage)" .

                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .

                    "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".

                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".

                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".

                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".

                    " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral', '$suppliers_id', '$_POST[danweijiage]')";

        }

        else

        {

            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .

                    "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .

                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .

                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .

                    "is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral, danweijiage)" .

                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .

                    "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".

                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".

                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".

                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".

                    " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral', '$_POST[danweijiage]')";

        }

}

修改为

 

    if ($is_insert)

    {

        if ($code == '')

        {

            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .

                    "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .

                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .

                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .

                    "is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id, danweijiage, tuijie_img)" .

                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .

                    "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".

                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".

                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".

                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".

                    " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral', '$suppliers_id', '$_POST[danweijiage]', '$tuijie_img')";

        }

        else

        {

            $sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .

                    "cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .

                    "promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .

                    "seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .

                    "is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral, danweijiage, tuijie_img)" .

                "VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .

                    "'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".

                    "'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".

                    "'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".

                    " '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".

                    " '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral', '$_POST[danweijiage]', '$tuijie_img')";

        }

    }

 

在代码

 

        $sql = "SELECT goods_thumb, goods_img, original_img " .

                    " FROM " . $ecs->table('goods') .

                    " WHERE goods_id = '$_REQUEST[goods_id]'";

        $row = $db->getRow($sql);

        if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))

        {

            @unlink(ROOT_PATH . $row['goods_img']);

            @unlink(ROOT_PATH . $row['original_img']);

        }

 

        if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))

        {

            @unlink(ROOT_PATH . $row['goods_thumb']);

        }

后面增加代码

 

              $sql = "SELECT tuijie_img" .

                    " FROM " . $ecs->table('goods') .

                    " WHERE goods_id = '$_REQUEST[goods_id]'";

              $row = $db->getRow($sql);

              if ($row['tuijie_img'])

        {

            @unlink(ROOT_PATH . $row['tuijie_img']);

        }

在代码

 

        if ($goods_img)

        {

            $sql .= "goods_img = '$goods_img', original_img = '$original_img', ";

        }

        if ($goods_thumb)

        {

            $sql .= "goods_thumb = '$goods_thumb', ";

        }

后面增加代码

             

        if($tuijie_img)

              {

                  $sql .= "tuijie_img = '$tuijie_img', ";

              }

ecshop 后台增加上传图片项

最近在研究ecshop,想后台添加/修改商品的时候,增加一个自己上传图片的功能,看了一下,修改如下 ( 还想在images/年月/下建立一个新的文件夹goods_new_img 准备:首先要先建...
  • shandianfocai
  • shandianfocai
  • 2015年12月01日 16:34
  • 1032

ECShop重命名上传图片名称及修改图片存储路径

ECShop从后台上传产品的图片分别存储在images文件夹下的goods_img、thumb_img、source_img三个文件夹下的,并且图片的名字都是随机产生的;本节主要是讲解如何对ECSho...
  • lcw2007101
  • lcw2007101
  • 2015年07月29日 15:13
  • 1834

ecshop商品相册批量上传

  • 2015年05月26日 18:53
  • 222KB
  • 下载

Ecshop商品详情批量上传图片插件终极版

  • 2013年10月30日 13:49
  • 396KB
  • 下载

Ecshop商品详情批量上传图片插件可用版

  • 2016年03月19日 20:06
  • 396KB
  • 下载

ecshop给分类上传图片

[类型]功能开发 [版本]ecshop2.7.2 [关键词]ecshop 分类图片 功能开发 ecshop的商品分类没有对就的分类图片,如果你需要为分类添加图片,然后在前端显示,可以按以下的步骤...
  • wangmj518
  • wangmj518
  • 2014年02月11日 00:26
  • 973

ecshop上传产品图片不显示的解决办法

按照如下3个步骤去解决 1,正在后台权限检测里,看看images权限是不是有,如果有的话往下看 2,后台起始页看看dg库是不是安装过了,有没有dg库版本,有的话往下看(我的就是没有安装dg库,起始页...
  • zhanglei1986410
  • zhanglei1986410
  • 2014年03月26日 18:39
  • 6535

ecshop商品详细描述页,批量上传图片功能实现

1、首先下载这个插件,网上好多
  • sa1176732685
  • sa1176732685
  • 2014年09月05日 11:56
  • 1696

ecshop 后台增加上传图片项

最近在研究ecshop,想后台添加/修改商品的时候,增加一个自己上传图片的功能,看了一下,修改如下 ( 还想在images/年月/下建立一个新的文件夹goods_new_img 准备:首先要先...
  • wangmj518
  • wangmj518
  • 2014年01月15日 09:48
  • 841

ecshop 完整去掉版权和后门

完整去掉版权和后门的方法: 去ECSHOP版权,去官方后门,完整版 作者:阿牛 ECShop是一款B2C独立网店系统,适合企业及个人快速构建个性化网上商店。系统开源但不免费,是基于...
  • yuan3065
  • yuan3065
  • 2016年05月17日 15:52
  • 8255
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Ecshop商品新增加一个图片上传功能
举报原因:
原因补充:

(最多只允许输入30个字)