上传了一份附件后,总是会有两份一样的附件存在,请教是哪里出问题了。附代码:
1 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 2 Dim names, url As String 3 Dim ss As String 4 If fileup1.PostedFile.FileName <> "" Then 5 Dim str As String = Me.fileup1.PostedFile.FileName 6 names = str.Substring((str.LastIndexOf("\") + 1) + 0) 7 Dim kuozhan As String = Right(names, 3) 8 Dim updates As String = ".asp|.php|.aspx|.jsp|.exe|.asa" 9 If updates.IndexOf(System.IO.Path.GetExtension(fileup1.PostedFile.FileName).ToLower()) > -1 Then 10 ss = "rar" 11 Else 12 ss = Right(fileup1.PostedFile.FileName, 3) 13 End If 14 Dim Route() As String = Split(fileup1.PostedFile.FileName, "\") 15 Dim returnValue As Integer 16 Dim instance As New Random 17 returnValue = instance.Next(500, 1000) 18 Dim FileName As String = Replace(Date.Today, "-", "") & Replace(TimeOfDay, ":", "") & returnValue & "." & ss 19 fileup1.PostedFile.SaveAs(Server.MapPath("upload\") & "bbs\" & FileName) 20 url = "upload/bbs/" + FileName 21 Content.Value = Replace(Content.Value, Chr(34), "'") & "<br>附件:<a href=" & url & ">" & names & "</a>" 22 If ss.ToLower = "jpg" Or ss.ToLower = "gif" Or ss.ToLower = "bmp" Then 23 Content.Value = Replace(Content.Value, Chr(34), "'") & "<br><p align=center><img src=" & url & " border=0 onload='if(this.width>590)this.width=590'></p>" 24 Else 25 Content.Value = Replace(Content.Value, Chr(34), "'") & "<br>附件:<a href=" & url & ">" & names & "</a>" 26 End If 27 End If 28 End Sub
下面的代码出现了2次
Content.Value = Replace(Content.Value, Chr(34), "'") & "<br>附件:<a href=" & url & ">" & names & "</a>"