主题: 共享本人的ASP版图片上传及动态显示到菜单中源码 |
作者: xdxxlh, 发布日期: 2009-05-22 15:06:33, 浏览数: 11641 |
先上图片: 步骤如下:1、在数据库中添加两个备注类型字段:SaveFileName(用来保存文件名),SavePathFileName(用来保存带路径的文件名),第二个字段主要是多了一个类似于0905的年月目录,我这样做的目的是为了在显示时调用SaveFileName,预览时调用SavePathFileName。 2、修改kindeditor\plugins目录下的image.html文件中的 <form name="uploadForm" method="post" enctype="multipart/form-data" action="../../admin/upload.asp"> 路径大家自己看着办吧。 3、upload.asp源代码: <!--#include file="conn.asp"--> <!--#include file="UpLoadClass.asp"--> <%Server.ScriptTimeOut=5000%> <% '调用网页头部代码(我的代码写在conn.asp,这个自己灵活处理) 'call header("上传图片") %> <body class="tdbg"> <script language="JavaScript" type="text/javascript"> function AddUploadFiles(objname,files,filesv){ if(objname!=''){ //alert("OK!"); var obj = parent.document.getElementById(objname); obj.options[obj.length]=new Option(filesv,files); } } function AddUploadFilesName(FileName1,FileName2){ var obj1=parent.document.myform.savefilename; var obj2=parent.document.myform.SavePathFileName; if (obj1.value.length>0) { obj1.value+="|" + FileName1; } else { obj1.value+=FileName1; } if (obj2.value.length>0) { obj2.value+="|" + FileName2; } else { obj2.value+=FileName2; } } </script> <% '定义常量(此处变量也可以) Const UploadPath="uploadfile/" '文件上传目录 Const UploadFileExt="bmp/gif/jpg/jpeg/png" '允许上传文件类型 Const UploadFileSize="200" '允许文件上传大小(单位:K) Dim request2,ArticleFolder,UploadFolderPath ArticleFolder=YCgetTime(Now,10) & "/" '设定当前年月目录 UploadFolderPath="../" & UploadPath & ArticleFolder '设置文件存放的路径 Call FolderNameCheck(UploadFolderPath) '检查文件夹 '建立上传对象 Set request2=New UpLoadClass 'request2.Charset="gb2312" '设置字符集 request2.MaxSize=UploadFileSize*1024 '设置上传文件的最大字节数 request2.FileType=UploadFileExt '设置允许上传文件的类型 request2.SavePath=UploadFolderPath '设置文件存放的路径 request2.AutoSave=0 '设置文件保存方式 request2.Open()'打开对象 If request2.Error=0 Then Response.Write "<script type=""text/javascript"">parent.insertHtml('content1', '<img src="&request2.SavePath & request2.Form("picture") &" border=0>');</script>" & vbCrlf Response.Write "<script type=""text/javascript"">AddUploadFiles('TempUploadFiles','"& ArticleFolder & request2.Form("picture") &"','"& request2.Form("picture") &"');</script>" & vbCrlf Response.Write "<script type=""text/javascript"">AddUploadFilesName('"& request2.Form("picture") &"','"& ArticleFolder & request2.Form("picture") &"');</script>" & vbCrlf Call Response.Write("<script>window.setTimeout(""location.href='Admin_Article_Upload.asp'"",0);</script>") Else Call Message(0,Err2Info(request2.Error),"?") 'Response.Write Err2Info(request2.Error) End If Set request2=Nothing Sub FolderNameCheck(FolderNameNew) '检查文件名是否含有特殊字符,如果含有则错误提示 Dim Letters,i,c,fso Letters="+=:;,[]<>\|*?" For i=1 To len(FolderNameNew) c=mid(FolderNameNew,i,1) If inStr(Letters,c)<>0 Then Call Message(0,"上传失败,文件夹名称含有特殊字符","?") End If Next '检查文件夹是否存在,如果不存在就创建文件夹 Set fso=Server.CreateObject("Scripting.FileSystemObject") If fso.FolderExists(server.MapPath(FolderNameNew))=False Then fso.CreateFolder(server.MapPath(FolderNameNew)) End If Set fso=Nothing End Sub Function Err2Info(Error) Select Case Error Case -1:Err2Info = "文件上传失败,请选择文件。" Case 0: Err2Info = "文件上传成功。" Case 1: Err2Info = "文件上传失败,不能上传超过"&UploadFileSize&"KB的文件。" Case 2: Err2Info = "文件上传失败,只允许上传后缀名为"""&Replace(UploadFileExt,"/",",")&"""的文件。" Case 3: Err2Info = "文件上传失败,不能上传超过"&UploadFileSize&"KB的文件,并且只允许上传后缀名为"""&Replace(UploadFileExt,"/",",")&"""的文件。" Case 4: Err2Info = "文件上传失败。" End Select End Function '============================================ '--格式化时间 '--tempTime 为所要格式化的时间 '--tempPar 取值为1、2、3、4、5、6、7、8,分别表示8种时间显示格式 '============================================ function YCgetTime(tempTime,tempPar) if IsDate(tempTime) then dim y : y = Year(tempTime) dim m : m = Month(tempTime) dim d : d = Day(tempTime) dim h : h = Hour(tempTime) dim n : n = Minute(tempTime) dim s : s = Second(tempTime) if m < 10 then m = "0"&m if d < 10 then d = "0"&d if h < 10 then h = "0"&h if n < 10 then n = "0"&n if s < 10 then s = "0"&s dim newTime select case tempPar case 1 : newTime = y&"-"&m&"-"&d&" "&h&":"&n&":"&s case 2 : newTime = y&"-"&m&"-"&d case 3 : newTime = y&"年"&m&"月"&d&"日"&h&"时"&n&"分"&s&"秒" case 4 : newTime = Right(y,2)&"年"&m&"月"&d&"日" case 5 : newTime = y&"年"&m&"月"&d&"日" case 6 : newTime = Right(y,2)&"-"&m&"-"&d case 7 : newTime = m&"-"&d case 8 : newTime = m&"月"&d&"日" Case 9 : newtime = y&m&d&h&n&s Case 10 : newtime = y&m end select YCgetTime = newTime else YCgetTime = tempTime end if end Function '============================================ '操作成功输出 '============================================ Function Message(byval tempPar,byval tempMessage,byval tempUrl) Call ConnEnd() dim tempString : tempString = "" select case tempPar case 0: tempString = "history.go(-1);" case 1: tempString = "window.location='"&tempUrl&"';" case 2: tempString = "window.parent.location='"&tempUrl&"';" case 3: tempString = "" end select if Right(tempMessage,2) = "\n" then tempMessage = Left(tempMessage,Len(tempMessage)-2) Response.Write("<"&"script>alert('"&tempMessage&"');"&tempString&"<"&"/script>") Response.End End Function %> </body> <%Call footer()%> |
作者: xdxxlh, 发布日期: 2009-05-22 15:07:48 |
4、UpLoadClass.asp源代码: <% '---------------------------------------------------------- '************** 风声 ASP 无组件上传类 V2.11 ************* '作者:风声 '网站:http://www.fonshen.com '邮件:webmaster@fonshen.com '版权:版权全体,源代码公开,各种用途均可免费使用 '********************************************************** '---------------------------------------------------------- Class UpLoadClass Private m_TotalSize,m_MaxSize,m_FileType,m_SavePath,m_AutoSave,m_Error,m_Charset Private m_dicForm,m_binForm,m_binItem,m_strDate,m_lngTime Public FormItem,FileItem Public Property Get Version Version="Fonshen ASP UpLoadClass Version 2.11" End Property Public Property Get Error Error=m_Error End Property Public Property Get Charset Charset=m_Charset End Property Public Property Let Charset(strCharset) m_Charset=strCharset End Property Public Property Get TotalSize TotalSize=m_TotalSize End Property Public Property Let TotalSize(lngSize) if isNumeric(lngSize) then m_TotalSize=Clng(lngSize) End Property Public Property Get MaxSize MaxSize=m_MaxSize End Property Public Property Let MaxSize(lngSize) if isNumeric(lngSize) then m_MaxSize=Clng(lngSize) End Property Public Property Get FileType FileType=m_FileType End Property Public Property Let FileType(strType) m_FileType=strType End Property Public Property Get SavePath SavePath=m_SavePath End Property Public Property Let SavePath(strPath) m_SavePath=Replace(strPath,chr(0),"") End Property Public Property Get AutoSave AutoSave=m_AutoSave End Property Public Property Let AutoSave(byVal Flag) select case Flag case 0,1,2: m_AutoSave=Flag end select End Property Private Sub Class_Initialize m_Error = -1 m_Charset = "gb2312" m_TotalSize= 0 m_MaxSize = 153600 m_FileType = "jpg/gif" m_SavePath = "" m_AutoSave = 0 Dim dtmNow : dtmNow = Date() m_strDate = Year(dtmNow)&Right("0"&Month(dtmNow),2)&Right("0"&Day(dtmNow),2) m_lngTime = Clng(Timer()*1000) Set m_binForm = Server.CreateObject("ADODB.Stream") Set m_binItem = Server.CreateObject("ADODB.Stream") Set m_dicForm = Server.CreateObject("Scripting.Dictionary") m_dicForm.CompareMode = 1 End Sub Private Sub Class_Terminate m_dicForm.RemoveAll Set m_dicForm = nothing Set m_binItem = nothing m_binForm.Close() Set m_binForm = nothing End Sub Public Function Open() Open = 0 if m_Error=-1 then m_Error=0 else Exit Function end if Dim lngRequestSize : lngRequestSize=Request.TotalBytes if m_TotalSize>0 and lngRequestSize>m_TotalSize then m_Error=5 Exit Function elseif lngRequestSize<1 then m_Error=4 Exit Function end if Dim lngChunkByte : lngChunkByte = 102400 Dim lngReadSize : lngReadSize = 0 m_binForm.Type = 1 m_binForm.Open() do m_binForm.Write Request.BinaryRead(lngChunkByte) lngReadSize=lngReadSize+lngChunkByte if lngReadSize >= lngRequestSize then exit do loop m_binForm.Position=0 Dim binRequestData : binRequestData=m_binForm.Read() Dim bCrLf,strSeparator,intSeparator bCrLf=ChrB(13)&ChrB(10) intSeparator=InstrB(1,binRequestData,bCrLf)-1 strSeparator=LeftB(binRequestData,intSeparator) Dim strItem,strInam,strFtyp,strPuri,strFnam,strFext,lngFsiz Const strSplit="'"">" Dim strFormItem,strFileItem,intTemp,strTemp Dim p_start : p_start=intSeparator+2 Dim p_end Do p_end = InStrB(p_start,binRequestData,bCrLf&bCrLf)-1 m_binItem.Type=1 m_binItem.Open() m_binForm.Position=p_start m_binForm.CopyTo m_binItem,p_end-p_start m_binItem.Position=0 m_binItem.Type=2 m_binItem.Charset=m_Charset strItem = m_binItem.ReadText() m_binItem.Close() intTemp=Instr(39,strItem,"""") strInam=Mid(strItem,39,intTemp-39) p_start = p_end + 4 p_end = InStrB(p_start,binRequestData,strSeparator)-1 m_binItem.Type=1 m_binItem.Open() m_binForm.Position=p_start lngFsiz=p_end-p_start-2 m_binForm.CopyTo m_binItem,lngFsiz if Instr(intTemp,strItem,"filename=""")<>0 then if not m_dicForm.Exists(strInam&"_From") then strFileItem=strFileItem&strSplit&strInam if m_binItem.Size<>0 then intTemp=intTemp+13 strFtyp=Mid(strItem,Instr(intTemp,strItem,"Content-Type: ")+14) strPuri=Mid(strItem,intTemp,Instr(intTemp,strItem,"""")-intTemp) intTemp=InstrRev(strPuri,"\") strFnam=Mid(strPuri,intTemp+1) m_dicForm.Add strInam&"_Type",strFtyp m_dicForm.Add strInam&"_Name",strFnam m_dicForm.Add strInam&"_Path",Left(strPuri,intTemp) m_dicForm.Add strInam&"_Size",lngFsiz if Instr(strFnam,".")<>0 then strFext=Mid(strFnam,InstrRev(strFnam,".")+1) else strFext="" end if select case strFtyp case "image/jpeg","image/pjpeg","image/jpg" if Lcase(strFext)<>"jpg" then strFext="jpg" m_binItem.Position=3 do while not m_binItem.EOS do intTemp = Ascb(m_binItem.Read(1)) loop while intTemp = 255 and not m_binItem.EOS if intTemp < 192 or intTemp > 195 then m_binItem.read(Bin2Val(m_binItem.Read(2))-2) else Exit do end if do intTemp = Ascb(m_binItem.Read(1)) loop while intTemp < 255 and not m_binItem.EOS loop m_binItem.Read(3) m_dicForm.Add strInam&"_Height",Bin2Val(m_binItem.Read(2)) m_dicForm.Add strInam&"_Width",Bin2Val(m_binItem.Read(2)) case "image/gif" if Lcase(strFext)<>"gif" then strFext="gif" m_binItem.Position=6 m_dicForm.Add strInam&"_Width",BinVal2(m_binItem.Read(2)) m_dicForm.Add strInam&"_Height",BinVal2(m_binItem.Read(2)) case "image/png" if Lcase(strFext)<>"png" then strFext="png" m_binItem.Position=18 m_dicForm.Add strInam&"_Width",Bin2Val(m_binItem.Read(2)) m_binItem.Read(2) m_dicForm.Add strInam&"_Height",Bin2Val(m_binItem.Read(2)) case "image/bmp" if Lcase(strFext)<>"bmp" then strFext="bmp" m_binItem.Position=18 m_dicForm.Add strInam&"_Width",BinVal2(m_binItem.Read(4)) m_dicForm.Add strInam&"_Height",BinVal2(m_binItem.Read(4)) case "application/x-shockwave-flash" if Lcase(strFext)<>"swf" then strFext="swf" m_binItem.Position=0 if Ascb(m_binItem.Read(1))=70 then m_binItem.Position=8 strTemp = Num2Str(Ascb(m_binItem.Read(1)), 2 ,8) intTemp = Str2Num(Left(strTemp, 5), 2) strTemp = Mid(strTemp, 6) while (Len(strTemp) < intTemp * 4) strTemp = strTemp & Num2Str(Ascb(m_binItem.Read(1)), 2 ,8) wend m_dicForm.Add strInam&"_Width", Int(Abs(Str2Num(Mid(strTemp, intTemp + 1, intTemp), 2) - Str2Num(Mid(strTemp, 1, intTemp), 2)) / 20) m_dicForm.Add strInam&"_Height",Int(Abs(Str2Num(Mid(strTemp, 3 * intTemp + 1, intTemp), 2) - Str2Num(Mid(strTemp, 2 * intTemp + 1, intTemp), 2)) / 20) end if end select m_dicForm.Add strInam&"_Ext",strFext m_dicForm.Add strInam&"_From",p_start if m_AutoSave<>2 then intTemp=GetFerr(lngFsiz,strFext) m_dicForm.Add strInam&"_Err",intTemp if intTemp=0 then if m_AutoSave=0 then strFnam=GetTimeStr() if strFext<>"" then strFnam=strFnam&"."&strFext end if m_binItem.SaveToFile Server.MapPath(m_SavePath&strFnam),2 m_dicForm.Add strInam,strFnam end if end if else m_dicForm.Add strInam&"_Err",-1 end if end if else m_binItem.Position=0 m_binItem.Type=2 m_binItem.Charset=m_Charset strTemp=m_binItem.ReadText if m_dicForm.Exists(strInam) then m_dicForm(strInam) = m_dicForm(strInam)&","&strTemp else strFormItem=strFormItem&strSplit&strInam m_dicForm.Add strInam,strTemp end if end if m_binItem.Close() p_start = p_end+intSeparator+2 loop Until p_start+3>lngRequestSize FormItem=Split(strFormItem,strSplit) FileItem=Split(strFileItem,strSplit) Open = lngRequestSize End Function Private Function GetTimeStr() m_lngTime=m_lngTime+1 GetTimeStr=m_strDate&Right("00000000"&m_lngTime,8) End Function Private Function GetFerr(lngFsiz,strFext) dim intFerr intFerr=0 if lngFsiz>m_MaxSize and m_MaxSize>0 then if m_Error=0 or m_Error=2 then m_Error=m_Error+1 intFerr=intFerr+1 end if if Instr(1,LCase("/"&m_FileType&"/"),LCase("/"&strFext&"/"))=0 and m_FileType<>"" then if m_Error<2 then m_Error=m_Error+2 intFerr=intFerr+2 end if GetFerr=intFerr End Function Public Function Save(Item,strFnam) Save=false if m_dicForm.Exists(Item&"_From") then dim intFerr,strFext strFext=m_dicForm(Item&"_Ext") intFerr=GetFerr(m_dicForm(Item&"_Size"),strFext) if m_dicForm.Exists(Item&"_Err") then if intFerr=0 then m_dicForm(Item&"_Err")=0 end if else m_dicForm.Add Item&"_Err",intFerr end if if intFerr<>0 then Exit Function if VarType(strFnam)=2 then select case strFnam case 0:strFnam=GetTimeStr() if strFext<>"" then strFnam=strFnam&"."&strFext case 1:strFnam=m_dicForm(Item&"_Name") end select end if m_binItem.Type = 1 m_binItem.Open m_binForm.Position = m_dicForm(Item&"_From") m_binForm.CopyTo m_binItem,m_dicForm(Item&"_Size") m_binItem.SaveToFile Server.MapPath(m_SavePath&strFnam),2 m_binItem.Close() if m_dicForm.Exists(Item) then m_dicForm(Item)=strFnam else m_dicForm.Add Item,strFnam end if Save=true end if End Function Public Function GetData(Item) GetData="" if m_dicForm.Exists(Item&"_From") then if GetFerr(m_dicForm(Item&"_Size"),m_dicForm(Item&"_Ext"))<>0 then Exit Function m_binForm.Position = m_dicForm(Item&"_From") GetData = m_binForm.Read(m_dicForm(Item&"_Size")) end if End Function Public Function Form(Item) if m_dicForm.Exists(Item) then Form=m_dicForm(Item) else Form="" end if End Function Private Function BinVal2(bin) dim lngValue,i lngValue=0 for i = lenb(bin) to 1 step -1 lngValue = lngValue *256 + Ascb(midb(bin,i,1)) next BinVal2=lngValue End Function Private Function Bin2Val(bin) dim lngValue,i lngValue=0 for i = 1 to lenb(bin) lngValue = lngValue *256 + Ascb(midb(bin,i,1)) next Bin2Val=lngValue End Function Private Function Num2Str(num, base, lens) Dim ret,i ret = "" while(num >= base) i = num Mod base ret = i & ret num = (num - i) / base wend Num2Str = Right(String(lens, "0") & num & ret, lens) End Function Private Function Str2Num(str, base) Dim ret, i ret = 0 for i = 1 to Len(str) ret = ret * base + Cint(Mid(str, i, 1)) next Str2Num = ret End Function End Class %> |
回复 |
作者: xdxxlh, 发布日期: 2009-05-22 15:15:06 |
5、下面是添加文章页面 此页面主要是显示如何动态显示到文本框中的代码,其他代码不是本帖讨论重点,先省略,如有需要,再提供。 注:上传附件的那个功能稍后再发新帖。 Admin_Artilce.asp源码 <script language=javascript src='Admin.js'></script> <script type="text/javascript" charset="utf-8" src="../editor/kindeditor/kindeditor.js"></script> <script type="text/javascript"> KE.show({ id : 'content1', skinType: 'tinymce', filterMode : false, cssPath : './images/index.css' }); function insertHtml(id, html) { KE.util.focus(id); KE.util.selection(id); KE.util.insertHtml(id, html); } </script> <Script Language=JavaScript> // 表单提交客户端检测 function doSubmit(){ KE.util.setData("content1"); var content1 = document.myform.content.value; if (document.myform.title.value==""){ alert("文章标题不能为空!"); document.myform.title.focus(); return false; } if (document.myform.classid.value==""){ alert("文章类别不能为空!"); document.myform.classid.focus(); return false; } if (document.myform.classid.value=="-1"){ alert("请选择所属下级分类!"); return false; } if (content1 == "") { alert("内容不能为空"); return false; } } </Script> <script language="javascript" type="text/javascript"> function showadv1(){ if (document.myform.showuploadlist.checked == true) { uploadlist.style.display = ""; }else{ uploadlist.style.display = "none"; } } </script> <div class="admin_lump"> <div class="admin_tr"> <span class="admin_right">您现在的位置:<A HREF="?">文章管理中心</A> >> 添加文章</span> </div> </div> <form action="?Action=SaveAddNews" method="post" name="myform" id="myform" doSubmit();"> <input type=hidden name=savefilename value=""> <input type=hidden name=SavePathFileName value=""> <div class="admin_lump"> <div class="admin_title">添加文章</div> <div class="admin_tr"> <span class="admin_left">文章标题</span> <span class="admin_right"> <input name="title" type="text" id="title" value='' size=40 maxlength=50> <select name="FontType" id="FontType" /> <option value="0">字 形</option> <option value="0">规 则</option> <option value="1" >粗 体</option> <option value="2" >斜 体</option> <option value="3" >粗+斜</option> </select> <font class=red>*</font> <img border="0" src="images/Gcolor.gif" style="cursor:pointer;background-Color:;" onClick="Getcolor(this,'FontColor');updateTitleFont('Title');" title="选取标题颜色!" align="absmiddle" id="ColorBG" /> <input type=hidden name="FontColor" value='' maxlength=6 size=6 readonly> <a href="javascript:ClearColor('FontColor');ClearColor('ColorBG');updateTitleFont('Title');" class=blue>清空颜色值</a> </span> </div> <div class="admin_tr"> <span class="admin_left">文章类别</span> <span class="admin_right">此处代码省略</span> </div> <div class="admin_tr"> <span class="admin_left">所属专题</span> <span class="admin_right"><%=InitSelect("SpecialID", "", "", "", "Select title,id from "&YC_Special&" order by id", "请选择专题")%></span> </div> <div class="admin_tr"> <span class="admin_left">文章内容</span> <span class="admin_right"><textarea name="content" id="content1" style="height:350px;display:none"></textarea></span> </div> <div class="admin_tr"> <span class="admin_left">文章图片</span> <span class="admin_right"><input type=text name=picture value='' size=50 maxlength=100 /> <Input type=button name=selectfile Value='从已上传文件中选择' class=btn></span> </div> <div class="admin_tr"> <span class="admin_left">上传文件</span> <span class="admin_right"><iframe border="0" frameBorder="0" noResize scrolling="no" width="100%" src="Admin_Article_Upload.asp" height="22" vspace="0" hspace="0" marginwidth="0" marginheight="0"></iframe></span> </div> <div class="admin_tr" id=uploadlist style='display:none'> <span class="admin_left">已上传</span> <span class="admin_right"> <div class=float_left><select name="TempUploadFiles" style="width:400;height:132" size="2" /> <input type="button" class="btn" name="SetDefaultPic" value="设为首页图片" /> <div class=float_left>预览</div><div id=tdPreview class=float_left></div> </span> </div> <div class="admin_tr"> <span class="admin_left">文章来源</span> <span class="admin_right"><input type="form" name="from" size="50" value="本站"></span> </div> <div class="admin_tr"> <span class="admin_left">文章属性</span> <span class="admin_right"> <input type=checkbox name=Istop value="yes">固顶文章 <input type=checkbox name=hidden value="yes">隐藏文章</span> </div> <div class="admin_tr"> <span class="admin_left">更多选项</span> <span class="admin_right"><input type=checkbox name=showuploadlist /> </div> <div class="admin_tr"> <span class="admin_td"> <input type="hidden" name="add" value="yes"> <input name="Submit" type="submit" value="确认添加"> <input name="button2" type="button" value="返 回"> </span> </div> </div> </form> |
回复 |
作者: xdxxlh, 发布日期: 2009-05-22 15:17:07 |
6、下面是Admin.js源码: //清除文章标题颜色 function ClearColor(tcstr) { eval("window.document.all."+tcstr+".value='';window.document.all."+tcstr+".style.backgroundColor='';"); } //标题颜色选择窗口 function Getcolor(img_val,input_val) { var arr = showModalDialog("./Inc/selcolor.htm","s","dialogWidth=300px;dialogHeight=270px;status=0"); if (arr != null){ $(input_val).value = arr; img_val.style.backgroundColor = arr; } } //设置文章标题样式 function updateTitleFont(objname) { var t; var tObj=$("FontType"); switch(tObj.options[tObj.selectedIndex].value){ case "1":t = "font-weight: bold;";break; case "2":t = "font-style: italic;";break; case "3":t = "font-weight: bold;font-style: italic;";break; default:t ="" ;break; } if ($("FontColor").value!="") { t += "color:"+$("FontColor").value+";"; } $(objname).style.cssText=t; } function $() { return document.getElementById(arguments[0]); } //地址栏的图片预览 function doPreview(objname){ var obj=$(objname); if(obj.length==0) return false; var url=obj.value; if (url){ //url = url.replace("{$webdir}",Wpath); //url = url.replace("{$uploaddir}",Upath); var sExt=url.substr(url.lastIndexOf(".")+1); sExt=sExt.toUpperCase(); var sHTML; switch(sExt){ case "GIF": case "JPG": case "BMP": case "PNG": tdPreview.innerHTML = "<img class='PreviewPic' border='0' src='../uploadfile/" + url + "'>"; break; //case "SWF": // sHTML = "<img border=0 src='" + url + "' width='170' height='140'>"; // break; default: tdPreview.innerHTML = ""; break; } //tdPreview.innerHTML = sHTML; }else{ tdPreview.innerHTML = ""; } } //设为标题图片 function SetPicUrl(objname,Insobjname) { var obj=document.getElementById(objname); if(obj.length==0) return false; document.getElementById(Insobjname).value=obj.value; } //图片选择窗口 function SelectFiles(objname){ var arr=showModalDialog('Admin_Files.asp?FileType=SelectPic', '', 'dialogWidth:760px; dialogHeight:600px; help: no; scroll: yes; status: yes'); if(arr!=null){ var obj = $(objname); var strT=arr.split('|'); obj.value=strT[0]; } } //模板选择窗口 function SelectTemplets(objname){ var arr=showModalDialog('Admin_Files.asp?FileType=SelectTemplets', '', 'dialogWidth:760px; dialogHeight:600px; help: no; scroll: yes; status: yes'); if(arr!=null){ var obj = $(objname); var strT=arr.split('|'); obj.value=strT[0]; } } //删除提示 function Del(str) { if(confirm("删除" + str + "后不能恢复!确定要删除此" + str + "吗?")) return true; else return false; } //删除提示2 function Del2(str) { alert("此" + str + "下还有子" + str + ",必须先删除下属子" + str + "后才能删除此" + str + "!"); return false; } //清空提示 function Delnews(str) { if(confirm("清空" + str + "将删除" + str + "中的所有文章,并且不能恢复!确定要清空此" + str + "吗?")) return true; else return false; } //全选复选框 function checkAll() { for (var i=0;i<form1.elements.length;i++) { var e = form1.elements[i]; if (e.name != 'selectAll') e.checked = form1.selectAll.checked; } } //字符长度检测(汉字为2个字符) function LenStr(fData) { var intLength=0 for (var i=0;i<fData.length;i++) { if ((fData.charCodeAt(i) < 0) || (fData.charCodeAt(i) > 255)) intLength=intLength+2 else intLength=intLength+1 } //alert(intLength); return intLength; } //上传图片后自动填入多行文本框 function doChange(objText, objDrop){ if (!objDrop) return; var str = objText.value; var arr = str.split("|"); var nIndex = objDrop.selectedIndex; objDrop.length=1; for (var i=0; i<arr.length; i++){ objDrop.options[objDrop.length] = new Option(arr[i], arr[i]); } objDrop.selectedIndex = nIndex; } |
回复 |
作者: kingyp, 发布日期: 2009-08-16 20:46:14 |
你的源码,能不能给一份? QQ号:407064026 |
回复 |
作者: zsk, 发布日期: 2009-09-18 14:59:29 |
我也想要呀! 能不能发给我一份呢? 太感谢了! 我的邮箱: zsk526@QQ.com |
回复 |
作者: ljq, 发布日期: 2011-04-07 17:11:12 |
能否请你把你的源码发给我呢?感谢下先!!
我的邮箱:ljq2222@yahoo.com.cn |
回复 |