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

📄 upload.asp

📁 酷虎网同学录V1.0
💻 ASP
📖 第 1 页 / 共 2 页
字号:
			if blnForce then
				stmRequest.Position = clsData.Start
				stmRequest.Copyto stmData,lenB(clsData.value)
				on Error Resume Next
				.SavetoFile strFullName,2 'adSaveCreateOverWrite 
				if Err <> 0 then
					if objFs.FileExists(strFullName) then
						SavetoFile = 8 '文件不能保存,该文件正在被使用
					else
						SavetoFile = 16 '文件不能保存,请确定该目录具有可写权限
					end if
				else
					SavetoFile = 0
				End if
				on Error goto 0
			else
				if objFs.FileExists(strFullName) then
					SavetoFile = 32 '非强制覆盖状态,文件已经存在
				else
					stmRequest.position = clsData.Start
					stmRequest.copyto stmData,lenB(clsData.value)
					on Error Resume Next
					.SavetoFile strFullName,2 'adSaveCreateOverWrite 
					if Err <> 0 then
						SavetoFile = 16 '文件不能保存,请确定该目录具有可写权限
					else
						SavetoFile = 0
					End if
					on Error goto 0
				end if
			end if
			set objFs = nothing
			.close
		end with
		set stmData = nothing
	End Function
	Function GetPath(strFullName)
		dim strReturn
		strReturn = left(strFullName,InstrRev(strFullName,"\"))
		GetPath = strReturn
	End function
	'************************************************接口函数结束**********************************************************
	
End Class

'定义数据类(存放form数据)
class FormItem
	Private mName
	Private mValue
	Private mType '数据类型:二进制数据取1; 文本数据取0
	Private mFileName
	Private mContentType
	Private mStart '二进制数据的开始结束位置
	'*************属性设置开始********************************
	Public Property Get Name()
		name = mName
	end Property
	Public Property Let Name(byVal varData)
		mName = varData
	end Property
	Public Property Get Value()
		value = mValue
	end Property
	Public Property Let Value(byVal varData)
		mValue = varData
	end Property
	Public Property Get DataType()
		DataType = mType
	end Property
	Public  Property Let DataType(byVal varData)
		mType = varData
	end Property
	Public Property Get FileName()
		FileName = mFileName
	end Property
	Public Property Let FileName(byVal varData)
		mFileName = varData
	end Property
	Public Property Get ContentType()
		ContentType = mContentType
	end Property
	Public Property Let ContentType(byVal varData)
		mContentType = varData
	end Property
	Public Property Get Start()
		Start = mStart
	end Property
	Public Property Let Start(byVal varData)
		mStart = varData
	end Property
	'取得文件名
	Public Property Get  ShortFileName()
		dim strReturn
		strReturn = Mid(mFileName,InstrRev(mFileName,"\")+1)
		ShortFileName = strReturn
	End Property
	'*************属性设置结束********************************
	'******************私有函数开始******************************
	'返回高位在后的整数(Intel顺序)
	Private Function ConvertIntel(strTemp)
		dim i
		for i = 1 to lenB(strTemp)
			ConvertIntel = ConvertIntel + ascb( midb( strTemp, i, 1 ) ) * ( 2 ^ ( (i-1) * 8 ) )
		next
	end Function
	'返回高位在前的整数(Motorola顺序)
	Private Function ConvertMotorola(strTemp)
		dim i,j
		j = 0
		for i = lenB(strTemp) to 1 step -1
			ConvertMotorola = ConvertMotorola + ascb( midb( strTemp, i, 1 ) ) * ( 2 ^ ( j * 8 ) )
			j = j + 1
		next
	end Function
	
	'******************私有函数结束******************************
	
	'****************************************接口函数开始***************************************
		
	'处理图片信息
	Public Function IsImage(byRef imgWidth,byRef imgHeight,byRef imgType,byRef imgSize,byRef imgBit)
		if mType = 0 or LenB(mValue) = 0 then
			IsImage = false
			imgWidth  = -1
			imgHeight = -1
			imgType = "unknow"
			imgSize = -1
			imgBit = -1
			exit function
		end if
		
	  	dim flag
	  	flag = 0  '0 is not jpg/gif/png image; 1 is jpg/gif/png
	    '*********************************Check.jpg Start*****************************************************
		dim i_Depth
		if flag = 0 then 
			dim lngMarkerSize,tempstr,tstr,lngSize,flgFound,strTarget,lngpos,exitLoop
			tempstr = LeftB(mValue,10)
			tstr = chrb(255) & chrb(216) & chrb(255) & chrb(224) & chrb(0) & chrb(16) & chrb(74) & chrb(70) & chrb(73) & chrb(70)
			if strcomp(tempstr,tstr,0) = 0 then
				imgType = "JPG" '图片格式
				imgSize = lenB(mValue) '图片大小
				lngSize = imgSize
				flgFound = 0
				strTarget = chrb(255) & chrb(216) & chrb(255)
				flgFound = instrb(mValue, strTarget)
				lngPos = flgFound + 2
				ExitLoop = false
		
				do while ExitLoop = False and lngPos < lngSize
					do while ascb(midb(mValue, lngPos, 1)) = 255 and lngPos < lngSize
						lngPos = lngPos + 1
					loop
					if ascb(midb(mValue, lngPos, 1)) < 192 or ascb(midb(mValue, lngPos, 1)) > 195 then
						lngMarkerSize = ConvertMotorola(midb(mValue, lngPos + 1, 2))
						lngPos = lngPos + lngMarkerSize + 1
		      		else
		        		ExitLoop = True
					end if
				loop
				imgHeight = ConvertMotorola(midb(mValue,  lngPos +4, 2)) '图片高度
				imgWidth = ConvertMotorola(midb(mValue, lngPos +6, 2)) '图片宽度
		    	imgBit = ascb(midb(mValue, lngPos + 8, 1)) * 8 '图片色深
		    	flag=2
			else
				flag=0
			end if
		end if
		'*********************************Check.jpg End*****************************************************
		
		'*********************************Check.gif Start*****************************************************
		if flag = 0 then
			dim tstr2
			tempstr = Leftb(mValue,6)
			tstr = chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(57) & chrb(97)
			tstr2 = chrb(71) & chrb(73) & chrb(70) & chrb(56) & chrb(55) & chrb(97)
			if (strcomp(tempstr,tstr,0) = 0 or strcomp(tempstr,tstr2) = 0) and (lenB(mValue) > 12) then
				imgType = "GIF" '图片格式
				imgWidth = ConvertIntel(midb(mValue,7,2))  '图片宽度
				imgHeight = ConvertIntel(midb(mValue,9,2)) '图片高度
				imgBit = (ascb(midb(mValue, 11, 1)) and 112)/16 + 1 '图片色深
				imgSize = lenB(mValue) '图片大小
				flag = 2
			else 
				flag = 0
			end if
		end if
		'*********************************Check.gif End*****************************************************
		
		'*********************************Check.bmp Start*****************************************************
		if flag = 0 then
			tempstr = Leftb(mValue,2)
			tstr = chrb(Asc("B")) & chrb(Asc("M"))
			if (strcomp(tempstr,tstr,0) = 0) and (lenb(mValue) >32 ) then
				imgType = "BMP" '图片格式
				imgWidth = ConvertIntel(midb(mValue,19,4))  '图片宽度
				imgHeight = ConvertIntel(midb(mValue,23,4)) '图片高度
				imgBit = ConvertIntel(midb(mValue,29,2)) '图片色深
				imgSize = lenB(mValue) '图片大小
				flag=2
			else 
				flag=0
			end if
		end if
		'*********************************Check.bmp End*****************************************************
		
		'*********************************Check.png Start*****************************************************
		if flag = 0 then 
			dim i_colorType
			tempstr=Leftb(mValue,8)
			tstr=chrb(137) & chrb(80) & chrb(78) & chrb(71) & chrb(13) & chrb(10) & chrb(26) & chrb(10)
			if (strcomp(tempstr,tstr,0) = 0) and (lenb(mValue) >27 )then
				imgType = "PNG" '图片格式
				imgWidth  = ConvertMotorola(midb(mValue, 19, 2)) '图片宽度
				imgHeight = ConvertMotorola(midb(mValue, 23, 2)) '图片高度
				i_Depth  = ascb(midb(mValue, 25, 1))
				i_colorType = ascb(midb(mValue, 26, 1))
				select case i_colorType
					case 0
						i_Depth = i_Depth
					case 2
						i_Depth = i_Depth * 3
					case 3
						i_Depth = i_Depth
					case 4
						i_Depth = i_Depth * 2
					case 6
						i_Depth = i_Depth * 4
					case else
						i_Depth = -1
				end select
				imgBit = i_Depth '图片色深
				imgSize = lenB(mValue) '图片大小
				flag = 2
			else 
				flag = 0
			end if
		end if
		
		'*********************************Check.png End*****************************************************
		if flag = 0 then 
			isImage = false
			imgWidth  = -1
			imgHeight = -1
			imgType = "unknow"
			imgSize = -1
			imgBit = -1
		else
			IsImage = true
		end if
	End Function
	'*************************************************接口函数结束***********************************************
end class

%>

⌨️ 快捷键说明

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