上传图片

    Sub UploadFile(ByVal sender As Object, ByVal e As EventArgs)
        If fileup.PostedFile.ContentLength = 0 Then
            FileInfo.Visible = False
            Exit Sub
        Else
            FileInfo.Visible = True
        End If
        '显示上传文件的信息
        fsize.Text = CStr(fileup.PostedFile.ContentLength)
        ftype.Text = fileup.PostedFile.ContentType
        fname.Text = fileup.PostedFile.FileName
        '储存上传的文件
        Dim filesplit() As String = Split(fileup.PostedFile.FileName, "/")
        Dim filename As String = filesplit(filesplit.Length - 1)
        Dim filename1() As String = Split(filename, ".")
        Dim nametime As String
        nametime = Now()
        nametime = Replace(nametime, ":", "")
        nametime = Replace(nametime, "-", "")
        nametime = Replace(nametime, " ", "")
        filename = nametime + "." + filename1(filename1.Length - 1)
        'Response.Write(filename)
        'Response.End()
        fileup.PostedFile.SaveAs(Server.MapPath(".") & "/images/" & filename)
        Dim strcnn As String
        Dim cmd As OleDbCommand
        Dim myconn As OleDbConnection
        Dim strsql As String
        Dim noid As Integer
        Dim path As String
        noid = CInt(Request("id"))
        strcnn = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("../../fluxay/mydbfluxay.mdb")
        myconn = New OleDbConnection(strcnn)
        myconn.Open()
        path = "images/" + filename
        strsql = "update game set path='" + path.ToString + "' where id=" & noid
        'Response.Write(strsql)
        'Response.End()
        cmd = New OleDbCommand(strsql, myconn)
        cmd.ExecuteNonQuery()
        myconn.Close()
        Response.Write("<script>alert('图片保存成功');</script>")
    End Sub
  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值