打印本文 打印本文 关闭窗口 关闭窗口
稻农的无组件上传程序ASP.NET版
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2037  更新时间:2009/4/23 10:40:56  文章录入:mintao  责任编辑:mintao
大小!"
                            Return False
                        End If

                    Else
                        ErrMsg = "对不起,只允许上传以下格式的文件" & LocAllowExtFile & "!"
                        Return False
                    End If

                End If
            End If

        Else
            ErrMsg = "上传目录未设置"
            Return False
        End If

        Return True


    End Function


    ''''-----------------------------------------------------------------------------------------
    ''''功能说明:根据日期和时间得到一个不重复的随机数文件名
    ''''-----------------------------------------------------------------------------------------
    Public Function GetRandomFileName(ByVal strFileName As String, ByVal strExtName As String) As String

        Dim tempFileName As String
        Dim Ext As String

        tempFileName = CStr(Now())
        tempFileName = Replace(tempFileName, "-", "")
        tempFileName = Replace(tempFileName, ":", "")
        tempFileName = Replace(tempFileName, " ", "")
        tempFileName = tempFileName & GetRandomNumber(1, 1000)

        GetRandomFileName = tempFileName & strExtName

    End Function

    ''''----------------------------------------------------------------------------------------
    ''''功能说明:获取指定上下限内的随机数
    ''''-----------------------------------------------------------------------------------------

    Public Function GetRandomNumber(Optional ByVal Low As Integer = 1, Optional ByVal High As Integer = 100) As Integer
        Dim oRandom As System.Random

        oRandom = New System.Random(CType(System.DateTime.Now.Ticks Mod System.Int32.MaxValue, Integer))
        Return oRandom.Next(Low, High + 1)

    End Function

    ''''------------------------------------------------------------------------------------
    ''''功能说明:根据文件名,得到扩展名
    ''''------------------------------------------------------------------------------------

    Public Function GetExtName(ByVal strFileName As String) As String
        Return Right(strFileName, InStr(StrReverse(strFileName), "."))
    End Function

End Class

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口