• ECSHOP产品内容页新增上传功能


    第一步:在 admin emplatesgoods_info.htm中

      <span class="tab-back" id="article-tab">{$lang.tab_article}</span>后面加上
      <span class="tab-back" id="file-tab">上传附件</span>

    现在确定按钮的前面加入

     <table width="90%" id="file-table" style="display:none" align="center">
        <tr>
            <td >上传附件:</td>
            <td><input type="file" name="file">
              <span class="narrow-label">{$lang.file_url}
              <input name="file_url" type="text" value="{$goods.file_url|escape}" size="30" maxlength="255" />
              </span></td>
             </tr>
     </table>

    第二步:在数据库的ECS_GOODS表中加入一个字段,这个自己去命名

    第三步:在admin/goods.php 中

        // 是否上传商品缩略图
        if (isset($_FILES['goods_thumb']) && $_FILES['goods_thumb']['tmp_name'] != '' &&
    ---------在这个代码的前面加入

        /* 取得文件地址 */
        $file_url = '';
        if ((isset($_FILES['file']['error']) && $_FILES['file']['error'] == 0) || (!isset($_FILES['file']['error']) && isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name'] != 'none'))
        {
            // 检查文件格式
            if (!check_file_type($_FILES['file']['tmp_name'], $_FILES['file']['name'], $allow_file_types))   {
                sys_msg($_LANG['invalid_file']);
            }

            // 复制文件
            $res = upload_article_file($_FILES['file']);
            if ($res != false) {
                $file_url = $res;
            }
        }

        if ($file_url == '')  {
            $file_url = $_POST['file_url'];
        }

        /* 计算文章打开方式 */
        if ($file_url == '')    {
            $open_type = 0;
        } else {
            $open_type = $_POST['FCKeditor1'] == '' ? 1 : 2;
        }

    第四步:搜索代码  /* 入库 */ 在SQL语句中加入你在第二步增加的字段。

    第五步:搜索"goods_desc = '$_POST[goods_desc]', " .   找到后复制一个,再把"goods_desc = '$_POST[goods_desc]', " . 中的两个goods_desc 改成你新增的字段值

    第六步:在$goods_thumb = reformat_image_name('goods_thumb', $goods_id, $goods_thumb, 'thumb');后面加入

     if ($file_url !== false){
            $db->query("UPDATE " . $ecs->table('goods') . " SET file_url = '$file_url' WHERE goods_id='$goods_id'");
        }

    大概位置在1100行左右

    第七步:在goods.dwt中加入

        {if $goods.file_url}
          <a href="{$goods.你新增的字段}" >下载</a>
       {else}
       暂未上传
       {/if}

  • 相关阅读:
    扩展json序列化datatime类型数据
    用select实现socket的IO多路复用
    Python单例模式
    Django(信号相关)
    将字符串按固定长度分隔成子串
    Android Handler介绍
    Android activity生命周期
    Java 启动线程的方式
    java线程中的sleep和wait区别
    JAVA 统计字符串中中文,英文,数字,空格的个数
  • 原文地址:https://www.cnblogs.com/zgzy/p/3569365.html
Copyright © 2020-2023  润新知