导航
当前位置:网站首页 > 站长新闻 > CMS教程 > 织梦让模型里的图片字段支持本地快速上传方法

织梦让模型里的图片字段支持本地快速上传方法

作者:达特 日期:2023-05-13 分类:CMS教程

本地上传效果

织梦让模型里的图片字段支持本地快速上传方法

修改教程
1、打开 \dede\js\main.js 找到
function SeePicNew(f, imgdid, frname, hpos, acname)
{
         中间代码...

}
把这整个函数改成

01 function SeePicNew(f, imgdid, frname, hpos, acname, formname, picname, picvalue)
02 {
03          var formname = formname ? formname : 'save';
04          var picname = picname ? picname : 'picname';
05          var picvalue = picvalue ? picvalue : 'picname';
06          var imgdid = imgdid ? imgdid : 'divpicview';
07          var newobj = null;
08          if(f.value=='') return ;
09          vImg = $Obj(imgdid);
10          picnameObj = document.getElementById(picname);
11          nFrame = $Nav()=='IE' ? eval('document.frames.'+frname) : $Obj(frname);
12          nForm = f.form;
13          if(nForm.detachEvent) nForm.detachEvent("onsubmit", checkSubmit);
14          else nForm.removeEventListener("submit", checkSubmit, false);
15          if(picname == 'picname') var picname = 'litpic';
16          nForm.action = 'archives_do.php?litpic='+picname+'&picname='+picvalue+'&divpicview='+imgdid;
17          nForm.target = frname;
18          nForm.dopost.value = 'uploadLitpic';
19          nForm.submit();
20          picnameObj.value = '';
21          newobj = $Obj('uploadwait');
22          if(!newobj)
23          {
24                    newobj = document.createElement("DIV");
25                    newobj.id = 'uploadwait';
26                    newobj.style.position = 'absolute';
27                    newobj.className = 'uploadwait';
28                    newobj.style.width = 120;
29                    newobj.style.height = 20;
30                    newobj.style.top = hpos;
31                    newobj.style.left = 100;
32                    newobj.style.display = 'block';
33                    document.body.appendChild(newobj);
34                    newobj.innerHTML = '<img src="images/loadinglit.gif" width="16" height="16" alit="" />上传中...';
35          }
36          newobj.style.display = 'block';
37          nForm.action = acname;
38          nForm.dopost.value = formname;
39          nForm.target = '';
40 }

2、打开 \dede\archives_do.php 找到
else if($dopost=="uploadLitpic")
{
       中间代码省略...
}
整个改成

01 else if($dopost=="uploadLitpic")
02 {
03     $fname = $_GET['litpic'] ? $_GET['litpic'] : 'litpic';
04     $upfile = AdminUpload($fname, 'imagelit', 0, true );
05     if($upfile=='-1')
06     {
07         $msg = "<script language='javascript'>
08                 parent.document.getElementById('uploadwait').style.display = 'none';
09                 alert('你没指定要上传的文件或文件大小超过限制!');
10             </script>";
11     }
12     else if($upfile=='-2')
13     {
14         $msg = "<script language='javascript'>
15                 parent.document.getElementById('uploadwait').style.display = 'none';
16                 alert('上传文件失败,请检查原因!');
17             </script>";
18     }
19     else if($upfile=='0')
20     {
21         $msg = "<script language='javascript'>
22                 parent.document.getElementById('uploadwait').style.display = 'none';
23                 alert('文件类型不正确!');
24             </script>";
25     }
26     else
27     {
28          if(!empty($cfg_uplitpic_cut) && $cfg_uplitpic_cut=='N')
29          {
30                  $msg = "<script language='javascript'>
31                     parent.document.getElementById('uploadwait').style.display = 'none';
32                     parent.document.getElementById('{$_GET[picname]}').value = '{$upfile}';
33                     if(parent.document.getElementById('{$_GET[divpicview]}'))
34                     {
35                  parent.document.getElementById('{$_GET[divpicview]}').style.width = '150px';
36                   parent.document.getElementById('{$_GET[divpicview]}').innerHTML = \"<img src='{$upfile}?n' width='150' />\";
37                     }
38                 </script>";
39          }
40          else
41          {
42                $msg = "<script language='javascript'>
43                     parent.document.getElementById('uploadwait').style.display = 'none';
44                     window.open('imagecut.php?f={$_GET[picname]}&isupload=yes&file={$upfile}', 'popUpImagesWin', 'scrollbars=yes,resizable=yes,statebar=no,
45                     width=800,height=600,left=150, top=50');
46                 </script>";
47          }
48     }
49     echo $msg;
50     exit();
51 }

3、打开 \include\customfields.func.php 找到

1 $innertext = "<input type='text' name='$fieldname' id='$fieldname' style='width:300px' />
2 <input name='".$fieldname."_bt' type='button' value='浏览...' onClick=\"SelectImage('form1.$fieldname','big')\" />\r\n"
改成
1 $innertext = "<input name='{$fieldname}' type='text' id='{$fieldname}' style='width:300px' value='' /><input type='button'  value='本地上传' style='width:70px;cursor:pointer;' />
2 <iframe name='upmy{$fieldname}fra' id='upmy{$fieldname}fra' src='' width='200' height='200' style='display:none'></iframe><span class='litpic_span'>
3 <input name='my{$fieldname}' type='file' id='my{$fieldname}' onChange=\"SeePicNew(this, 'divmy{$fieldname}view', 'upmy{$fieldname}fra', 165, '', 'save',
4 'my{$fieldname}', '{$fieldname}');\" size='1' class='np coolbg' style='cursor:pointer;height:20px;margin-left:-20px;opacity:0;width:85px;'/></span>
5 <input name='".$fieldname."_bt' type='button' class='inputbut' value='浏览...' onClick=\"SelectImageN('form1.$fieldname','big','$fieldname')\" />
6 <div id='divmy{$fieldname}view' class='divpre' style='display:inline-block;vertical-align:middle'></div>\r\n";
继续找到
1 $innertext = "<input type='text' name='$fieldname' value='$fvalue' id='$fieldname' style='width:300px'  class='text' /> <input name='".$fieldname."_bt' type='button' value='
2 浏览...' onClick=\"SelectImage('form1.$fieldname','big')\" />\r\n";
有2处,都改成
1 $imgstr = ($fvalue=='') ? '' : "<img src='{$fvalue}' width='150'>";
2 $innertext = "<input type='text' name='$fieldname' value='$fvalue'
3 id='$fieldname' style='width:300px'  class='text' /><input type='button'
4 value='本地上传' style='width:70px;cursor:pointer;' />
5 <iframe name='upmy{$fieldname}fra' id='upmy{$fieldname}fra' src='' width='200' height='200' style='display:none'></iframe><span>
6 <input name='my{$fieldname}' type='file' id='my{$fieldname}' onChange=\"SeePicNew(this, 'divmy{$fieldname}view',
7 'upmy{$fieldname}fra', 165, '', 'save', 'my{$fieldname}', '{$fieldname}');\" size='1' class='np coolbg' style='cursor:pointer;height:20px;margin-left:-20px;opacity:0;width:85px;'/>
8 </span> <input name='".$fieldname."_bt' type='button' value='浏览...' onClick=\"SelectImage('form1.$fieldname','big')\" />
9 <div id='divmy{$fieldname}view' style='display:inline-block;vertical-align:middle'>{$imgstr}</div>\r\n";
完结。
 

猜你还喜欢