通过ecshop广告管理上传各种后缀附件的方法


ecshop没有上传其它附件的功能.比如rar,doc文档等.可以通过万能的广告来实现,只有增加功能. 暂时没有编辑功能

一,修改admin\templates\ads_info.htm,18行上增加一句

 

<span style="font-family: monospace; white-space: pre; background-color: rgb(240, 240, 240);"> {if $action eq "add"}      <tr>        <td class="label">{$lang.media_type}</td>        <td>         <select name="media_type" onchange="showMedia(this.value)">         <option value='0'>{$lang.ad_img}</option>         <option value='1'>{$lang.ad_flash}</option>         <option value='2'>{$lang.ad_html}</option>         <option value='3'>{$lang.ad_text}</option> <option value='4'>其它后缀的文件</option>         </select>        </td></span>
	
	

 

然后, 在120行左右增加这一句

 

{if $ads.media_type eq 4 OR $action eq "add"}
    <tbody id="4" style="{if $ads.media_type neq 4 OR $action eq 'add'}display:none{/if}">
    <tr>
      <td  class="label">
       其它类型文件</td>
      <td>
        <input type='file' name='upfile_other' size='35' />
        <br /><span class="notice-span" style="display:block;color:red" >注意,这里可以上传任何后缀的文件,比如rar,doc文档,docx,ppt等,<br/>但文件名称中只能使用用英文字母及下划线,比如word_2015_help.doc这种形式<br/>如果上传文件与原上传的文件重名,原文件将会被替换.</span>
      </td>
    </tr>
 
    </tbody>
  {/if}


最下面的js增加一个数组成员

 

 

var MediaList = new Array('0', '1', '2', '3','4');

 


二,修改admin/ads.php

 

在238行左右增加这一段

  
	/* 新增,如果添加的广告是其它后缀文件 */
    elseif ($_POST['media_type'] == '4')
    {
        if ((isset($_FILES['upfile_other']['error']) && $_FILES['upfile_other']['error'] == 0) || (!isset($_FILES['upfile_other']['error']) && isset($_FILES['upfile_other']['tmp_name']) && $_FILES['upfile_other']['tmp_name'] != 'none'))
        {
          

            /* 生成文件名 */
             // $urlstr = date('Ymd');
            // for ($i = 0; $i < 6; $i++)
            // {
              // $urlstr .= chr(mt_rand(97, 122));
           // }

            $source_file = $_FILES['upfile_other']['tmp_name'];
            $target      = ROOT_PATH . DATA_DIR . '/afficheimg/';
           $file_name   = $_FILES['upfile_other']['name'];
            if (!move_upload_file($source_file, $target.$file_name))
            {
                $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
                sys_msg($_LANG['upfile_error'], 0, $link);
            }
            else
            {
                $ad_code = $file_name;
            }
        }
		
    

        if (((isset($_FILES['upfile_other']['error']) && $_FILES['upfile_other']['error'] > 0) || (!isset($_FILES['upfile_other']['error']) && isset($_FILES['upfile_other']['tmp_name']) && $_FILES['upfile_other']['tmp_name'] == 'none')) && empty($_POST['other_url']))
        {
            $link[] = array('text' => $_LANG['go_back'], 'href' => 'javascript:history.back(-1)');
            sys_msg('文件不能为空', 0, $link);
        }
    }

 



最下面的函数function get_adslist()修改下

 

 

.$rows['type'] .= ($rows['media_type'] == 3) ? $GLOBALS['_LANG']['ad_text']  : '';
$rows['type'] .= ($rows['media_type'] == 4) ? '其它后缀文件'  : '';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值