求asp无组件上传 源码,寻求ASP代码,BAT批处理中循环执行程序的代码...
求asp无组件上传 源码
上传图片最大730宽限jpg格式
//fileuploads.asp
文件上传
<!--
function checkcom(){
if (document.form1.pic.value==""){
alert("一定要有文件才可以!");
return false;
}
return true;
}
//-->
图 片 上 传
<%
If Request.QueryString("action") = "up" Then
'on error resume next
dim upload,file,formName,formPath,iCount,pic
set upload=new upload_5xsoft ''建立上传对象
' Response.End
set file=upload.file("pic")
if file.FileSize>0 then
pic = file.FileName
sFileSave = lcase(Mid(pic, InStrRev(pic,".")))
if sFileSave ".jpg" and sFileSave ".gif" and sFileSave ".bmp" then
strMsg="alert('只接受jpg,gif,bmp的图形文件!');history.back();"
Response.write strMsg
Response.end
end If
sFileSave=GetRndFileName&sFileSave
file.SaveAs Server.MapPath("../uploadpic")&"/"&sFileSave
pic=sFileSave
end if
set file = nothing
set upload = nothing
%>
//opener.form1.FileName.value = ""
//opener.form1.Width.value = ""
//opener.form1.Height.value = ""
opener.document.all.form.picurl.value = ""
//alert("成功!");
setTimeout("window.close()",1000);
<%
response.write ""
Response.End
End If
%>
&action=up" onSubmit="return checkcom();">
图 片 上 传
<%
Function GetRndFileName()
Dim tmpstr
randomize
tmpstr=Int(1000*rnd)
tmpstr=""&year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&tmpstr
GetRndFileName=tmpstr
End Function
%>
//upload_5xsoft.inc
dim Data_5xsoft
Class upload_5xsoft
dim objForm,objFile,Version
Public function Form(strForm)
strForm=lcase(strForm)
if not objForm.exists(strForm) then
Form=""
else
Form=objForm(strForm)
end if
end function
Public function File(strFile)
strFile=lcase(strFile)
if not objFile.exists(strFile) then
set File=new FileInfo
else
set File=objFile(strFile)
end if
end function
Private Sub Class_Initialize
dim RequestData,sStart,vbCrlf,sInfo,iInfoStart,iInfoEnd,tStream,iStart,theFile
dim iFileSize,sFilePath,sFileType,sFormValue,sFileName
dim iFindStart,iFindEnd
dim iFormStart,iFormEnd,sFormName
Version="化境HTTP上传程序 Version 2.0"
set objForm=Server.CreateObject("Scripting.Dictionary")
set objFile=Server.CreateObject("Scripting.Dictionary")
if Request.TotalBytes<1 then Exit Sub
set tStream = Server.CreateObject("adodb.stream")
set Data_5xsoft = Server.CreateObject("adodb.stream")
Data_5xsoft.Type = 1
Data_5xsoft.Mode =3
Data_5xsoft.Open
Data_5xsoft.Write Request.BinaryRead(Request.TotalBytes)
Data_5xsoft.Position=0
RequestData =Data_5xsoft.Read
iFormStart = 1
iFormEnd = LenB(RequestData)
vbCrlf = chrB(13) & chrB(10)
sStart = MidB(RequestData,1, InStrB(iFormStart,RequestData,vbCrlf)-1)
iStart = LenB (sStart)
iFormStart=iFormStart+iStart+1
while (iFormStart + 10) < iFormEnd
iInfoEnd = InStrB(iFormStart,RequestData,vbCrlf & vbCrlf)+3
tStream.Type = 1
tStream.Mode =3
tStream.Open
Data_5xsoft.Position = iFormStart
Data_5xsoft.CopyTo tStream,iInfoEnd-iFormStart
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sInfo = tStream.ReadText
tStream.Close
'取得表单项目名称
iFormStart = InStrB(iInfoEnd,RequestData,sStart)
iFindStart = InStr(22,sInfo,"name=""",1)+6
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFormName = lcase(Mid (sinfo,iFindStart,iFindEnd-iFindStart))
'如果是文件
if InStr (45,sInfo,"filename=""",1) > 0 then
set theFile=new FileInfo
'取得文件名
iFindStart = InStr(iFindEnd,sInfo,"filename=""",1)+10
iFindEnd = InStr(iFindStart,sInfo,"""",1)
sFileName = Mid (sinfo,iFindStart,iFindEnd-iFindStart)
theFile.FileName=getFileName(sFileName)
theFile.FilePath=getFilePath(sFileName)
'取得文件类型
iFindStart = InStr(iFindEnd,sInfo,"Content-Type: ",1)+14
iFindEnd = InStr(iFindStart,sInfo,vbCr)
theFile.FileType =Mid (sinfo,iFindStart,iFindEnd-iFindStart)
theFile.FileStart =iInfoEnd
theFile.FileSize = iFormStart -iInfoEnd -3
theFile.FormName=sFormName
if not objFile.Exists(sFormName) then
objFile.add sFormName,theFile
end if
else
'如果是表单项目
tStream.Type =1
tStream.Mode =3
tStream.Open
Data_5xsoft.Position = iInfoEnd
Data_5xsoft.CopyTo tStream,iFormStart-iInfoEnd-3
tStream.Position = 0
tStream.Type = 2
tStream.Charset ="gb2312"
sFormValue = tStream.ReadText
tStream.Close
if objForm.Exists(sFormName) then
objForm(sFormName)=objForm(sFormName)&", "&sFormValue
else
objForm.Add sFormName,sFormValue
end if
end if
iFormStart=iFormStart+iStart+1
wend
RequestData=""
set tStream =nothing
End Sub
Private Sub Class_Terminate
if Request.TotalBytes>0 then
objForm.RemoveAll
objFile.RemoveAll
set objForm=nothing
set objFile=nothing
Data_5xsoft.Close
set Data_5xsoft =nothing
end if
End Sub
Private function GetFilePath(FullPath)
If FullPath "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, "\"))
Else
GetFilePath = ""
End If
End function
Private function GetFileName(FullPath)
If FullPath "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
End Class
Class FileInfo
dim FormName,FileName,FilePath,FileSize,FileType,FileStart
Private Sub Class_Initialize
FileName = ""
FilePath = ""
FileSize = 0
FileStart= 0
FormName = ""
FileType = ""
End Sub
Public function SaveAs(FullPath)
dim dr,ErrorChar,i
SaveAs=true
if trim(fullpath)="" or FileStart=0 or FileName="" or right(fullpath,1)="/" then exit function
set dr=CreateObject("Adodb.Stream")
dr.Mode=3
dr.Type=1
dr.Open
Data_5xsoft.position=FileStart
Data_5xsoft.copyto dr,FileSize
dr.SaveToFile FullPath,2
dr.Close
set dr=nothing
SaveAs=false
end function
End Class
上传到上一个目录的uploadpic里面
寻求ASP代码
登录状态,都是用session来记录的, 默认session是20分钟,可以通过修改session.timeout=1440 这是24小时。。 当然如果你还需要时间更久的话,可以通过写入COOKIES来实现,然后能过JS来判断关闭状态,来清除COOKIES就可以了。 还有一个办法: 设置页面为每15分钟自动刷新一次:比如: 还有一些办法: function keepsession(){ document.all["Back"].src="/SessionKeeper.asp?RandStr="+Math.random(); //这里的RandStr=Math.random只是为了让每次back.src的值不同,防止同一地址刷新无效的情况 window.setTimeout("keepsession()",900000); //每隔900秒调用一下本身 } keepsession(); 在根目录建立一个空的SessionKeeper.asp文件就可以了,让JS通过指定时间来刷新一次,也可以保持SESSION的值。。。 建议还是不要做session保持,可以登录时加上个保持登录选项,如果选了就用cookies来实现就可以了。
BAT批处理中循环执行程序的代码
vbs 安静,用vbs吧
do
wscript.sleep 3000
createobject("wscript.shell").run "delete.bat"
loop
保存为vbs
-----------------------------------------
如果想停止这一动作
就复制下面的代码
getobject("winmgmts:\\.\root\cimv2").execquery("select * from win32_process where name='wscript.exe'")
保存为另一个vbs
如果一定要用bat的话,还得后台运行,是很占用cpu的,要启动ping.exe.这样非常的卡!
-----------------------------------------
@echo off&call:. delete.bat
:.
for /l %%1 in (0)do ping /n 60 127.1>nul&start "" "%1"
::60=30余秒
这是批处理,保存为批处理类型文件
下一篇:没有了