结分后仔细看了一下,上传后的文件还是带原来的文件名啊?我想改文件名就是想把原来的文件名给去掉啊~~~老大们再帮帮忙了

解决方案 »

  1.   

    下面是孟老大的多文件上传程序,我想改成上传后自动改名,在代码
    postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("images/") + fileName)
    前面加了
    Dim FileName111 As String = Path.GetFileName(fileName)     
                    fileName = Now()
                    fileName = Replace(fileName, "-", "")
                    fileName = Replace(fileName, ":", "")
                    fileName = Replace(fileName, " ", "")
                    fileName = fileName
                    fileName = fileName & Strx & Right(Path.GetFileName(FileName111), Len(Path.GetFileName(FileName111)) - (InStr(Path.GetFileName(FileName111), ".")) + 1)现在是按时间改名了,可是上传多个文件后,前面的文件就被后面的文件覆盖了,求各位大侠帮忙解决这个问题!谢谢!(问题解决立即送分,在线等)孟老大多文件上传代码:
     Private Function SaveImages() As System.Boolean
        '遍历File表单元素
        Dim files As System.Web.HttpFileCollection = System.Web.HttpContext.Current.Request.Files    '状态信息
        Dim strMsg As New System.Text.StringBuilder("上传的文件分别是:<hr color=red>")
        Dim iFile As System.Int32
        Try
          For iFile = 0 To files.Count - 1
            '检查文件扩展名字
            Dim postedFile As System.Web.HttpPostedFile = files(iFile)
            Dim fileName, fileExtension As System.String
            fileName = System.IO.Path.GetFileName(postedFile.FileName)
            If Not (fileName = String.Empty) Then
              fileExtension = System.IO.Path.GetExtension(fileName)
              strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br/>")
              strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br/>")
              strMsg.Append("上传文件的文件名:" + fileName + "<br/>")
              strMsg.Append("上传文件的扩展名:" + fileExtension + "<br/><hr>")
              '可根据扩展名字的不同保存到不同的文件夹
              postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("images/") + fileName)
            End If
          Next
          strStatus.Text = strMsg.ToString()
          Return True
        Catch Ex As System.Exception
          strStatus.Text = Ex.Message
          Return False
        End Try
      End Function