想做一个文件上传的小东东,我想把很多页面的文件都上传到一个指定的文件夹,比如说image
我现在只会用Server.MapPath,但是不能满足要求,我该怎么办????????????急啊!
asp.net(C#)

解决方案 »

  1.   

    为什么不行??
    你的这些页面是不是都不在同一个路径的?
    改改Server.MapPath的参数就可以了啊看看MSDN上面对Server.MapPath的解释,就几句而已
      

  2.   

    看看MapPath的用法吧
    你指定一下它的相对路径
      

  3.   

    会有什么问题呢?无非就是指定的server.mappath() 中的路径改一下.根目录下 u1 文件夹 u1.aspx    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            If FileUpload1.HasFile Then
                FileUpload1.PostedFile.SaveAs(Server.MapPath("../upload/") & Now.ToString("yyyyMMddhhmmss") & System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName))
            End If
        End Sub根目录下 u2 文件夹 u2.aspx    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            If FileUpload1.HasFile Then
                FileUpload1.PostedFile.SaveAs(Server.MapPath("../upload/") & Now.ToString("yyyyMMddhhmmss") & System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName))
            End If
        End Sub根目录下 u3.aspx    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            If FileUpload1.HasFile Then
                FileUpload1.PostedFile.SaveAs(Server.MapPath("upload/") & Now.ToString("yyyyMMddhhmmss") & System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName))
            End If
        End Sub