织梦广告管理功能增加图片上传
- 2020 年 3 月 6 日
- 笔记
文章时间:2020年3月4日 19:33:39 解决问题:广告管理功能增加图片上传功能

先上效果图,图片后面,点击浏览即可上传图片。
需要修改的位置,下面请大家直接复制查找,然后替换即可。
涉及到的文件列表:dede如果修改了名称,请自行对应
dede/ad_add.php dede/ad_edit.php dede/templets/ad_add.htm dede/templets/ad_edit.htm
01 ad_add.php
查找
$normbody = "<a href="{$link}"><img src="{$normbody['url']}"$width $height border="0" /></a>";
替换
$normbody = "}" id="qyuef"><img src="{$pic}"$width $height border="0" />>";
02 ad_edit.php
查找
$endtime = GetMkTime($endtime);
下方添加代码
if($img=="qyuefimg"){ $normbody = "<a href="{$piclink}" id="qyuef"><img src="{$pic}" border="0" /></a>";}
03 ad_add.htm
查找
<script type="text/javascript" src="js/calendar/calendar.js"></script>
下方添加
<script language="javascript" src="../include/js/dedeajax2.js"></script> <script language='javascript' src="js/main.js"></script>
查找
<td class="b"><input type="text" size="40" name="normbody[url]" value="" class='iptxt'/></td>
替换
<td class="b"> <input type="text" size="40" name="pic" id="pic" value="" class='iptxt'/> <input type="button" name="Submit" value="浏览..." style="width:70px" onClick="SelectImage('form1.pic','');"></span> </td>
04 ad_edit.htm
查找
<script type="text/javascript" src="js/calendar/calendar.js"></script>
下方添加
<script language="javascript" src="../include/js/dedeajax2.js"></script> <script language='javascript' src="js/main.js"></script>
查找(大约在82行左右)
<td width="76%"><textarea name="normbody" rows="10" id="normbody" style="width:80%;height:100"><?php echo htmlspecialchars(stripslashes($row['normbody']))?></textarea></td> <td width="9%"> </td> </tr> <tr> <td height="80" align="center">过期显示内容:</td> <td><textarea name="expbody" rows="10" id="expbody" style="width:80%;height:100"><?php echo htmlspecialchars($row['expbody'])?></textarea></td>
替换
<td width="76%"> <?php if(strstr($row['normbody'],'id="qyuef"')) { $pat = '/<a[^>]*?s*href="(.*?)"(.*?)>(.*?)</a>/i'; preg_match_all($pat,$row['normbody'], $m); $piclink=$m[1][0]; $pic=$m[3][0]; $pattern="/<[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg]))['|"].*?[/]?>/"; preg_match_all($pattern,$pic,$match); $qyuefpic=$match[1][0] ?> <input type="hidden" size="40" name="img" id="img" value="qyuefimg" class='iptxt'/> <input type="text" size="40" name="pic" id="pic" value="<?php echo $qyuefpic?>" class='iptxt'/> <input type="button" name="Submit" value="浏览..." style="width:70px" onClick="SelectImage('form1.pic','');"></span> <tr> <td height="80" align="center">图片链接:</td> <td><input type="text" size="40" name="piclink" id="piclink" value="<?php echo $piclink?>" class='iptxt'/></td> <td> </td> </tr> <?php }else{ ?> <textarea name="normbody" rows="10" id="normbody" style="width:80%;height:100"><?php echo $row['normbody']?></textarea> <?php } ?> <tr> <td height="80" align="center">过期显示内容:</td> <td><textarea name="expbody" rows="10" id="expbody" style="width:80%;height:100"><?php echo $row['expbody']?></textarea></td>