1
Partial Class admin_upload
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim UpPath As String
        Dim UpName As String
        UpPath = "/images"
        UpName = Dir(UpPath, vbDirectory)
        If (UpName = "") Then
            MkDir("/images")
        End If
    End Sub

    Protected Sub uplodto_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uplodto.Click
        FileName.InnerHtml = FileFiled.PostedFile.FileName
        FileContent.InnerHtml = FileFiled.PostedFile.ContentType
        FileSize.InnerHtml = FileFiled.PostedFile.ContentLength
        UploadDetails.Visible = True
        Dim myfilename As String
        myfilename = FileFiled.PostedFile.FileName
        Dim c As String = System.IO.Path.GetFileName(myfilename)
        Try
            FileFiled.PostedFile.SaveAs("images\" + c)
            Span1.InnerHtml = "File uploaded successfuly"
        Catch ex As Exception
            Span1.InnerHtml = "faild"
            UploadDetails.Visible = False
        End Try
    End Sub
End Class

我想在网站文件夹和服务器上确定文件的方向

4

1 回答 1

0

If Not System.IO.Directory.Exists(Server.MapPath("~/images/")) Then System.IO.Directory.CreateDirectory(Server.MapPath("~/images/")) End If

于 2013-01-05T06:02:28.510 回答