通过ecshop广告管理上传各种后缀附件的方法
来源:互联网 发布:网络重置怎么弄 编辑:程序博客网 时间:2024/05/18 09:40
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
- 通过ecshop广告管理上传各种后缀附件的方法
- ecshop调用指定广告的方法
- 多附件上传的方法
- 多附件上传的方法
- 多附件上传的方法
- ecshop广告调用方法总结
- ecshop广告调用方法总结
- 邮件系统使用的上传附件方法
- 邮件系统使用的上传附件方法
- sencha touch上传附件的方法
- ECSHOP添加广告位的方法,并且去掉广告链接
- 通用附件上传方法
- 上传附件方法
- 通过web service的方式上传附件和下载附件,以及内存溢出问题
- 上传附件的实现
- 附件的上传
- Struts2的上传附件
- 上传附件的限制
- 敏捷看板的递进
- C++STL之multimap多重映照容器
- 贡献30本经典Linux学习和开发教程和资料,都是pdf完整版的
- [自我解剖]别把时间浪费在工具上
- 【C/C++学习笔记】结构体的位域操作小结
- 通过ecshop广告管理上传各种后缀附件的方法
- programming-challenges Is Bigger Smarter? (111101) 题解
- Quartz2D
- <body>标签
- 蓝牙4.0基础知识
- LOG: mac homebrew安装mysql后 配置文件location
- HTML5—视频插入—video元素的属性、事件与方法
- <p>标签
- php session_start()关于Cannot send session cache limiter - headers already sent 错误解决方法