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

📄 uploadfun.asp

📁 电子商务网络购物系统
💻 ASP
字号:
<%
Function fileUpload(ByVal strFileUploadPath, ByVal saryFileUploadTypes, ByVal intMaxFileSize, ByVal strUploadComponent, ByRef lngErrorFileSize, ByRef blnExtensionOK)

	Dim objUpload
	Dim strNewFileName
	Dim strOriginalFileName

	Select Case strUploadComponent
		Case "AspUpload"
			Set objUpload = Server.CreateObject("Persits.Upload.1")
			With objUpload
				.OverwriteFiles = False
				.SaveVirtual strFileUploadPath
				strNewFileName = .Files(1).ExtractFileName
				strNewFileName = Replace(strNewFileName, " ", "_", 1, -1, 1)
				strNewFileName = Replace(strNewFileName, "(", "", 1, -1, 1)
				strNewFileName = Replace(strNewFileName, ")", "", 1, -1, 1)
				lngErrorFileSize = fileSize(.Files(1).Size, intMaxFileSize)
				blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)
				If lngErrorFileSize = 0 AND blnExtensionOK = True Then
					Do While .FileExists(Server.MapPath(strFileUploadPath) & "\" & strNewFileName)
						strNewFileName = hexValue(3) & "_" & strNewFileName
					Loop
					.Files(1).CopyVirtual strFileUploadPath & "\" & strNewFileName
					.Files(1).Delete
					fileUpload = strNewFileName
				Else
					.Files(1).Delete
				End If
			End With
			Set objUpload = Nothing

		Case "Dundas"
			Set objUpload = Server.CreateObject("Dundas.Upload")
			With objUpload
				.UseVirtualDir = True
				.UseUniqueNames = False
				.SaveToMemory()
				strNewFileName = .GetFileName(.Files(0).OriginalPath)
				strNewFileName = Replace(strNewFileName, " ", "_", 1, -1, 1)
				lngErrorFileSize = fileSize(.Files(0).Size, intMaxFileSize)
				blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)
				If lngErrorFileSize = 0 AND blnExtensionOK = True Then
					Do While .FileExists(strFileUploadPath & "\" & strNewFileName)
						strNewFileName = hexValue(3) & "_" & strNewFileName
					Loop
					.Files(0).SaveAs strFileUploadPath & "\" & strNewFileName
					fileUpload = strNewFileName
				End If
			End With
			Set objUpload = Nothing

		Case "fileUp"
			Dim objSAFileManager
			Set objUpload = Server.CreateObject("SoftArtisans.FileUp")
			With objUpload
				.OverWriteFiles = True
				.Path = Server.MapPath(strFileUploadPath)
				strNewFileName = Mid(.UserFilename, InstrRev(.UserFilename, "\") + 1)
				strNewFileName = Replace(strNewFileName, " ", "_", 1, -1, 1)
				lngErrorFileSize = fileSize(.TotalBytes, intMaxFileSize)
				blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)
				If lngErrorFileSize = 0 AND blnExtensionOK = True Then
					Set objSAFileManager = Server.CreateObject("SoftArtisans.FileManager")
					Do While objSAFileManager.FileExists(Server.MapPath(strFileUploadPath) & "\" & strNewFileName)
						strNewFileName = hexValue(3) & "_" & strNewFileName
					Loop
					Set objSAFileManager = Nothing
					.SaveAs strNewFileName
					fileUpload = strNewFileName
				End If
			End With
			Set objUpload = Nothing

		Case "aspSmart"
			Set objUpload = Server.CreateObject("aspSmartUpload.SmartUpload")
			With objUpload
				.DenyPhysicalPath = True
				.Upload
				strNewFileName = .Files(1).Filename
				strNewFileName = Replace(strNewFileName, " ", "_", 1, -1, 1)
				lngErrorFileSize = fileSize(.Files(1).Size, intMaxFileSize)
				blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)
				If lngErrorFileSize = 0 AND blnExtensionOK = True Then
					strNewFileName = hexValue(5) & "_" & strNewFileName
					.Files(1).SaveAs strFileUploadPath & "/" & strNewFileName
					fileUpload = strNewFileName
				End If
			End With
			Set objUpload = Nothing

		Case "AspSimple"
			Dim objFso
			Dim file
			Set objUpload = Server.CreateObject("ASPSimpleUpload.Upload")
			With objUpload
				strOriginalFileName = .ExtractFileName(.Form("file"))
				strNewFileName = "TMP" & hexValue(7) & "_" & strOriginalFileName
				Call .SaveToWeb ("file", strFileUploadPath & "/" & strNewFileName)
				Set objFso = Server.CreateObject("Scripting.FileSystemObject")
				Set file = objFso.GetFile(Server.MapPath(strFileUploadPath) & "\" & strNewFileName)
				lngErrorFileSize = fileSize(file.Size, intMaxFileSize)
				strNewFileName = strOriginalFileName
				strNewFileName = Replace(strNewFileName, " ", "_", 1, -1, 1)
				blnExtensionOK = fileExtension(strNewFileName, saryFileUploadTypes)
				If lngErrorFileSize = 0 AND blnExtensionOK = True Then
					Do While objFso.FileExists(Server.MapPath(strFileUploadPath) & "\" & strNewFileName)
						strNewFileName = hexValue(3) & "_" & strNewFileName
					Loop
					Call .SaveToWeb("file", strFileUploadPath & "\" & strNewFileName)
					file.Delete
					fileUpload = strNewFileName
				End If
			End With
			Set file = Nothing
			Set objFso = Nothing
			Set objUpload = Nothing
	End Select
End Function

Function fileSize(ByVal lngFileSize, ByVal intMaxFileSize)
	If CInt(lngFileSize / 1024) > intMaxFileSize Then
		fileSize = CInt(lngFileSize / 1024)
	Else
		fileSize = 0
	End If
End Function

Function fileExtension(ByVal strFileName, ByVal saryFileUploadTypes)
	Dim intExtensionLoopCounter
	fileExtension = False
	For intExtensionLoopCounter = 0 To UBound(saryFileUploadTypes)
		If LCase(Right(strFileName, Len(saryFileUploadTypes(intExtensionLoopCounter)))) = LCase(saryFileUploadTypes(intExtensionLoopCounter)) Then fileExtension = True
	Next
End Function
%>

⌨️ 快捷键说明

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