一款基于webupload的帝國cms后臺多圖集H5上傳插件。
使用方法:
1、將webupload文件放到/e/extend/目錄下
2、新建字段uploadimg,將下面的代碼放入“輸入表單替換html代碼”中
3、修改一下兩個文件
打開/e/class/qinfofun.php文件找到
if($f=="morepic")//圖片集
在下面放入代碼
elseif($f=='uploadimg') { $add_temp = array( 'msmallpic' => $add['msmalluploadimg'], 'mbigpic' => $add['mbiguploadimg'], 'mpicname' => $add['muploadimgname'], 'mdelpicid' => $add['mdeluploadimgid'], 'mpicid' => $add['muploadimgid'], 'mpicurl_qz'=> $add['muploadimgurl_qz'], 'msavepic' => $add['msaveuploadimg'], 'mcreatespic'=> $add['mcreatesuploadimg'], 'msmallpfile'=> $add['msmalluploadimgfile'], 'mbigpfile'=> $add['mbiguploadimgfile'], ); //設置_FIELS $_FILES['msmallpfile'] = $_FILES['msmalluploadimgpfile']; $_FILES['mbigpfile'] = $_FILES['mbiguploadimgpfile']; $add = array_merge($add,$add_temp); $value=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],1,0,intval($add['fstb'])); }
打開/e/class/functions.php文件找到
elseif($f=="morepic")//圖片集
在下面放入代碼(總共兩個位置分別放入)
elseif($f=='uploadimg') { $add_temp = array( 'msmallpic' => $add['msmalluploadimg'], 'mbigpic' => $add['mbiguploadimg'], 'mpicname' => $add['muploadimgname'], 'mdelpicid' => $add['mdeluploadimgid'], 'mpicid' => $add['muploadimgid'], 'mpicurl_qz'=> $add['muploadimgurl_qz'], 'msavepic' => $add['msaveuploadimg'], 'mcreatespic'=> $add['mcreatesuploadimg'], 'msmallpfile'=> $add['msmalluploadimgpfile'], 'mbigpfile'=> $add['mbiguploadimgpfile'], ); //設置_FIELS $_FILES['msmallpfile'] = $_FILES['msmalluploadimgpfile']; $_FILES['mbigpfile'] = $_FILES['mbiguploadimgpfile']; $add = array_merge($add,$add_temp); $value=ReturnMorepicpath($add['msmallpic'],$add['mbigpic'],$add['mpicname'],$add['mdelpicid'],$add['mpicid'],$add,$add['mpicurl_qz'],1,0,intval($add['fstb'])); }
最后新建好文章的圖集字段 字段命名為[ uploadimg ]
<link rel="stylesheet" type="text/css" href="<?=$public_r[newsurl]?>e/extend/webupload/webuploader.css" /> <link rel="stylesheet" type="text/css" href="<?=$public_r[newsurl]?>e/extend/webupload/style.css" /> <script type="text/javascript" src="<?=$public_r[newsurl]?>e/extend/webupload/jquery-1.8.3.min.js"></script> <script type="text/javascript"> var mys="<?=$public_r[newsurl]?>e/extend/webupload/up.php"; var myfileNumLimit=5; var myformData={'classid':'<?=$classid?>','filepass':'<?=$filepass?>'}; </script> <div id="wrapper"> <div id="container"> <div id="uploader"> <div class="queueList"> <div id="dndArea" class="placeholder<?=$r[uploadimg]?' element-invisible':''?>"> <div id="filePicker"></div> <p>點擊選擇圖片,單次最多可選5張</p> </div> <ul class="filelist" id="filelist0"> <? if($r[uploadimg]) { $r['uploadimg']=stripSlashes($r[uploadimg]); $picarr=explode("\r\n",$r[uploadimg]); $count=count($picarr); for($i=0;$i<$count;$i++) { $j=$i+1; $pic=explode("::::::",$picarr[$i]); $checked=$pic[0]==$r[titlepic]?'checked':''; $uploadimg.='<li class="delpic courseList"> <p class="title">'.$pic[2].'</p> <p class="imgWrap"><img style="width:120px; height:90px;" src="'.$pic[0].'"><input type="hidden" name="mbiguploadimg[]" value="'.$pic[1].'" /><input type="hidden" name="msmalluploadimg[]" value="'.$pic[0].'" /><input type="text" id="muploadimgname" name="muploadimgname[]" value="'.$pic[2].'" /></p> <div class="file-panel"><input type="radio" value="'.$pic[1].'" '.$checked.' name="setTitlepic" class="setTitlepic" />設為封面</div> <span class="cancel">刪除</span> <div class="moveud"><a class="moveUpBtn" href="javascript:;"><</a><a class="moveDownBtn" href="javascript:;">></a></div> </li>'; } } echo $uploadimg; ?> <script> //設置封面 $(document).on('click', '.setTitlepic', function(){ titlepic=$(this).val(); $("#titlepic").val(titlepic); }); //動態(tài)刪除DOM添加的圖片 $(document).on('click', 'span.cancel', function(){ $(this).parents('.courseList').remove(); }); //靜態(tài)DOM設置封面 $(document).on('click', '.setTitlepic', function(){ titlepic=$(this).val(); $("#titlepic").val(titlepic); }); //靜態(tài)刪除DOM添加的圖片 $(document).on('click', 'span.cancel', function(){ $(this).parents('.courseList').remove(); }); $(document).on('click', '.moveDownBtn', function(){ //判斷是否有下一個節(jié)點 if($(this).parents('.courseList').nextAll().length > 0){ $(this).parents('.courseList').next().after($(this).parents('.courseList').prop('outerHTML')); $(this).parents('.courseList').remove(); } }).on('click', '.moveUpBtn', function(){ //判斷是否有上一個節(jié)點 if($(this).parents('.courseList').prevAll().length > 0){ $(this).parents('.courseList').prev().before($(this).parents('.courseList').prop('outerHTML')); $(this).parents('.courseList').remove(); } }) </script> </ul> </div> <div class="statusBar" style="<?=$r[uploadimg]?'':'display:none;'?>"> <div class="progress"> <span class="text">0%</span> <span class="percentage"></span> </div> <div class="btns"> <div class="uploadBtn">開始上傳</div> <div id="filePicker2"></div> </div> <div class="info"></div> </div> </div> </div> </div> <script type="text/javascript" src="<?=$public_r[newsurl]?>e/extend/webupload/webuploader.min.js"></script> <script type="text/javascript" src="<?=$public_r[newsurl]?>e/extend/webupload/upload.js"></script> <script type="text/javascript"> $(function(){ $("#filelist1").html($("#filelist0").html()); $("#filelist0").remove(); }) </script>