首页 新闻 会员 周边 捐助

VB写的代码关于上传附件的问题。

0
悬赏园豆:10 [已解决问题] 解决于 2018-02-05 17:19

上传了一份附件后,总是会有两份一样的附件存在,请教是哪里出问题了。附代码:

 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
View Code
JenasYang的主页 JenasYang | 初学一级 | 园豆:146
提问于:2018-01-17 16:47
< >
分享
最佳答案
0

下面的代码出现了2次

Content.Value = Replace(Content.Value, Chr(34), "'") & "<br>附件:<a href=" & url & ">" & names & "</a>"
收获园豆:10
dudu | 高人七级 |园豆:30948 | 2018-01-17 17:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册