<% function CovHtml(content) ONERRORRESUMENEXT CovHtml=content ifnotisnull(content) then CovHtml=replace(CovHtml,"&","&") CovHtml=replace(CovHtml,"<","<") CovHtml=replace(CovHtml,">",">") CovHtml=replace(CovHtml,chr(34),""") CovHtml=replace(CovHtml,chr(39),"'") endif if Err.Number <>0then CovHtml="CovHtml转换中出错请联系管理员<br>" Err.Clear endif end function %>
js文件 edit.js
// JavaScript Document var bodyTag="<head><style type="text/css">body {font-size: 9pt}</style><meta http-equiv=Content-Type content="text/html; charset=gb2312"></head><BODY bgcolor="#FFFFFF" MONOSPACE>" function document.onreadystatechange()...{ HtmlEdit.document.open() HtmlEdit.document.write(bodyTag); HtmlEdit.document.close() HtmlEdit.document.designMode="On" } function format(what,value)...{ if(what !="")...{ if(value !="")...{ HtmlEdit.document.execCommand(what,"",value); }else...{ HtmlEdit.document.execCommand(what); } } HtmlEdit.focus(); } function insert(what)...{ if(what =="img")...{ var arr = showModalDialog("edithtml_include/images/image.htm","","dialogWidth:430px;dialogHeight:230px;status:0"); if (arr !=null)...{ content=HtmlEdit.document.body.innerHTML; content=content+arr; HtmlEdit.document.body.innerHTML=content; } }elseif(what =="flash")...{ var arr = showModalDialog("edithtml_include/images/flash.htm","","dialogWidth:430px;dialogHeight:200px;status:0"); if (arr !=null)...{ content=HtmlEdit.document.body.innerHTML; content=content+arr; HtmlEdit.document.body.innerHTML=content; } }elseif(what =="avi")...{ var arr = showModalDialog("edithtml_include/images/video.htm","","dialogWidth:430px;dialogHeight:200px;status:0"); if (arr !=null)...{ content=HtmlEdit.document.body.innerHTML; content=content+arr; HtmlEdit.document.body.innerHTML=content; } }elseif(what =="color")...{ var arr = showModalDialog("edithtml_include/images/select.htm","","dialogWidth:18.5em; dialogHeight:17.5em; status:0"); if (arr !=null) format('forecolor', arr); } HtmlEdit.focus(); } function CheckForm()...{ content=HtmlEdit.document.body.innerHTML; document.form_edit.remark.value = content; } function loadForm()...{ HtmlEdit.document.body.innerHTML=document.form_edit.remark.value; } setTimeout('loadForm();',1000);
<% Server.ScriptTimeout =9999999 %> <style type="text/css"> <!-- body { background-color: #D4D0C8; margin:0px; font-size:12px; } --> </style> <!--#include file="upload.inc"--> <% err.Clear nPath=server.MapPath("/edithtml_include/upfile/up_file/") set upl=new upload_5xsoft set file=upl.file("FileName") If file.fileSize>0then Randomize cfileName=file.fileName ifinstr(UCase(cfileName),".ASP")>0Orinstr(UCase(cfileName),".EXE")>0then %> <script language='javascript'> alert('文件类型不合法!请重新选择文件'); this.location.href='upfile.html'; </script> <% response.end endif upfilename=split(file.fileName,".") namekzm=upfilename(ubound(upfilename)) filename="edit_"&replace(replace(replace(now(),"-",""),":",""),"","")&"."&namekzm file.saveAs npath&""&filename EndIf If err.Number=0Then %> <script language='javascript'> var filename ="<%=filename%>" var webpath = document.location.href; //http://lvlingwy.u-vv.com/work/syradioword/edithtml_include/upfile/upfilewrite.asp var getpath = webpath.substr(0,webpath.indexOf('upfile/')+7) var newfilepath = getpath +"up_file/"+ filename ; parent.imgurl.value = newfilepath; parent.showupfileinput(); this.location.href='upfile.html'; </script> <%Else%> <script language='javascript'> alert('文件上传失败,请重新上传'); this.location.href='upfile.html'; </script> <%EndIf%>
无组件上传 upload.inc
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT> dim upfile_5xSoft_Stream Class upload_5xSoft dim Form,File,Version PrivateSub Class_Initialize dim iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile dim strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr Version="化境编程界HTTP上传程序 Version 1.0" if Request.TotalBytes<1thenExitSub set Form=CreateObject("Scripting.Dictionary") set File=CreateObject("Scripting.Dictionary") set upfile_5xSoft_Stream=CreateObject("Adodb.Stream") upfile_5xSoft_Stream.mode=3 upfile_5xSoft_Stream.type=1 upfile_5xSoft_Stream.open upfile_5xSoft_Stream.write Request.BinaryRead(Request.TotalBytes) vbEnter=Chr(13)&Chr(10) iDivLen=inString(1,vbEnter)+1 strDiv=subString(1,iDivLen) iFormStart=iDivLen iFormEnd=inString(iformStart,strDiv)-1 while iFormStart < iFormEnd iStart=inString(iFormStart,"name=""") iEnd=inString(iStart+6,"""") mFormName=subString(iStart+6,iEnd-iStart-6) iFileNameStart=inString(iEnd+1,"filename=""") if iFileNameStart>0and iFileNameStart<iFormEnd then iFileNameEnd=inString(iFileNameStart+10,"""") mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10) iStart=inString(iFileNameEnd+1,vbEnter&vbEnter) iEnd=inString(iStart+4,vbEnter&strDiv) if iEnd>iStart then mFileSize=iEnd-iStart-4 else mFileSize=0 endif set theFile=new FileInfo theFile.FileName=getFileName(mFileName) theFile.FilePath=getFilePath(mFileName) theFile.FileSize=mFileSize theFile.FileStart=iStart+4 theFile.FormName=FormName file.add mFormName,theFile else iStart=inString(iEnd+1,vbEnter&vbEnter) iEnd=inString(iStart+4,vbEnter&strDiv) if iEnd>iStart then mFormValue=subString(iStart+4,iEnd-iStart-4) else mFormValue="" endif form.Add mFormName,mFormValue endif iFormStart=iformEnd+iDivLen iFormEnd=inString(iformStart,strDiv)-1 wend End Sub PrivateFunction subString(theStart,theLen) dim i,c,stemp upfile_5xSoft_Stream.Position=theStart-1 stemp="" for i=1to theLen if upfile_5xSoft_Stream.EOS thenExitfor c=ascB(upfile_5xSoft_Stream.Read(1)) If c >127Then if upfile_5xSoft_Stream.EOS thenExitfor stemp=stemp&Chr(AscW(ChrB(AscB(upfile_5xSoft_Stream.Read(1)))&ChrB(c))) i=i+1 else stemp=stemp&Chr(c) EndIf Next subString=stemp End function PrivateFunction inString(theStart,varStr) dim i,j,bt,theLen,str InString=0 Str=toByte(varStr) theLen=LenB(Str) for i=theStart to upfile_5xSoft_Stream.Size-theLen if i>upfile_5xSoft_Stream.size thenexitFunction upfile_5xSoft_Stream.Position=i-1 if AscB(upfile_5xSoft_Stream.Read(1))=AscB(midB(Str,1)) then InString=i for j=2to theLen if upfile_5xSoft_Stream.EOS then inString=0 Exitfor endif if AscB(upfile_5xSoft_Stream.Read(1))<>AscB(MidB(Str,j,1)) then InString=0 ExitFor endif next if InString<>0thenExitFunction endif next End Function PrivateSub Class_Terminate form.RemoveAll file.RemoveAll set form=nothing set file=nothing upfile_5xSoft_Stream.close set upfile_5xSoft_Stream=nothing End Sub Privatefunction GetFilePath(FullPath) If FullPath <>""Then GetFilePath =left(FullPath,InStrRev(FullPath, "")) Else GetFilePath ="" EndIf Endfunction Privatefunction GetFileName(FullPath) If FullPath <>""Then GetFileName =mid(FullPath,InStrRev(FullPath, "")+1) Else GetFileName ="" EndIf Endfunction Privatefunction toByte(Str) dim i,iCode,c,iLow,iHigh toByte="" For i=1ToLen(Str) c=mid(Str,i,1) iCode =Asc(c) If iCode<0Then iCode = iCode +65535 If iCode>255Then iLow =Left(Hex(Asc(c)),2) iHigh =Right(Hex(Asc(c)),2) toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh) Else toByte = toByte & chrB(AscB(c)) EndIf Next End function End Class Class FileInfo dim FormName,FileName,FilePath,FileSize,FileStart PrivateSub Class_Initialize FileName ="" FilePath ="" FileSize =0 FileStart=0 FormName ="" End Sub Publicfunction SaveAs(FullPath) dim dr,ErrorChar,i SaveAs=1 iftrim(fullpath)=""or FileSize=0or FileStart=0or FileName=""thenexitfunction if FileStart=0orright(fullpath,1)="/"thenexitfunction set dr=CreateObject("Adodb.Stream") dr.Mode=3 dr.Type=1 dr.Open upfile_5xSoft_Stream.position=FileStart-1 upfile_5xSoft_Stream.copyto dr,FileSize dr.SaveToFile FullPath,2 dr.Close set dr=nothing SaveAs=0 end function End Class </SCRIPT>