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 准备:首先要先建...

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

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

ecshop 后台增加上传图片项

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

fileupload文件上传

不知道如何上传文件?看看FileUpload工具吧...(附框架类图),可以学习不少相关设计模式知识...

ecshop 后台增加上传图片项

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

自己写的一个图片上传功能

  • 2014年08月11日 14:32
  • 12.63MB
  • 下载

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

1、首先下载这个插件,网上好多

SSM综合项目实战(TTSC) -- day04 图片上传、商品列表

一、
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Ecshop商品新增加一个图片上传功能
举报原因:
原因补充:

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