⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 process.asp

📁 是个不错的文件代码,希望大家好好用,
💻 ASP
字号:
<!--#include file="inc/inc_syssite.asp"-->
<% 
dim formsize,mydata,freesize,maxsize,FilePath,my_name,filename
response.buffer=true 
formsize=request.totalbytes 
mydata=request.binaryread(formsize)
if not oblog.checkuserlogined() then
	response.Write("登录后才能保存大头贴")
	response.End()
end if
maxsize=oblog.l_Group(24,0)
freesize=int(maxsize-oblog.l_uUpUsed/1024)
if formsize/1024>freesize then
	response.Write("空间已满,请清理上传文件。")
	response.end
end if
if upload_dir<>"" then
	FilePath=upload_dir
else
	FilePath = oblog.l_udir&"/"&oblog.l_ufolder&"/upload"
end if

FilePath=CreatePath(FilePath)
filename=FormatName("jpg")
my_name= FilePath&filename
Call SaveStream(my_name,mydata)
oblog.execute("update oblog_user set user_upfiles_size=user_upfiles_size+"&formsize&" where userid="&oblog.l_uid)
oblog.execute("Insert into oblog_upfile (userid,file_name,file_path,file_ext,file_size,isphoto,sysclassid,userclassid,isBigHead) values ("&oblog.l_uid&",'"&filename&"','"&my_name&"','jpg',"&formsize&",1,0,0,1)")
Response.Write my_name

Sub SaveStream(paR_strFile, paR_streamContent)
	Dim objStream
	Set objStream =Server.CreateObject("ADODB.Stream")
		with objStream
			.Type =1
			.Open
			.Write paR_streamContent
			.SaveToFile Server.Mappath(paR_strFile), 2
			.Close()
		End with
	Set objStream =Nothing
End Sub

'检查上传目录,若无目录则自动建立
Function CreatePath(PathValue)
	Dim objFSO,Fsofolder,uploadpath
	if upload_dir<>"" then
		uploadpath = year(Date) & "-" & month(Date)
	else
		uploadpath=""
	end if
	If Right(PathValue,1)<>"/" Then PathValue = PathValue&"/"
	On Error Resume Next
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		If objFSO.FolderExists(Server.MapPath(PathValue & uploadpath))=False Then
			objFSO.CreateFolder Server.MapPath(PathValue & uploadpath)
		End If
		If Err.Number = 0 and upload_dir<>"" Then
			CreatePath = PathValue & uploadpath & "/"
		Else
			CreatePath = PathValue
		End If
	Set objFSO = Nothing
End Function

Function FormatName(Byval FileExt)
	Dim RanNum,TempStr
	Randomize
	RanNum = Int(900000*rnd)+100000
	'TempStr = Year(now) & Month(now) & Day(now) & RanNum & "." & FileExt
	TempStr = Month(now) & Day(now) & RanNum & "." & FileExt
	FormatName = TempStr
End Function
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -