补充一句HTML如下:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="addnew.aspx.vb" Inherits="ascatvgame.addnew"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>addnew</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body>
<form id="Form1" method="post" runat="server" enctype="multipart/form-data">
<FONT face="宋体">
<TABLE id="Table3" style="WIDTH: 190px; HEIGHT: 35px" cellSpacing="0" cellPadding="0" width="190" align="center" border="0">
<TR>
<TD align="middle">
<asp:Label id="Label10" runat="server" Font-Bold="True">新闻添加</asp:Label>&nbsp;
</TD>
</TR>
</TABLE>
<TABLE id="Table1" style="WIDTH: 530px; HEIGHT: 588px" cellSpacing="0" cellPadding="0" width="530" align="center" border="1" borderColorDark="#000099">
<TR>
<TD style="WIDTH: 90px; HEIGHT: 34px" align="middle">
<asp:Label id="Label1" runat="server" Font-Size="X-Small">类型</asp:Label></TD>
<TD style="HEIGHT: 34px">&nbsp;
<asp:DropDownList id="type" runat="server" Width="100px">
<asp:ListItem Value="sc" Selected="True">sc</asp:ListItem>
<asp:ListItem Value="FIFA">FIFA</asp:ListItem>
<asp:ListItem Value="WarⅢ">WarⅢ</asp:ListItem>
<asp:ListItem Value="CS">CS</asp:ListItem>
<asp:ListItem Value="竞技">竞技</asp:ListItem>
<asp:ListItem Value="周边">周边</asp:ListItem>
</asp:DropDownList></TD>
</TR>
<TR>
<TD style="WIDTH: 90px; HEIGHT: 24px" align="middle" colSpan="1" rowSpan="1">
<asp:Label id="Label2" runat="server" Font-Size="X-Small">标题</asp:Label></TD>
<TD style="HEIGHT: 24px">&nbsp;
<asp:TextBox id="title" runat="server" Width="368px"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 90px; HEIGHT: 28px" align="middle" colSpan="1" rowSpan="1">
<asp:Label id="Label3" runat="server" Font-Size="X-Small">内容</asp:Label></TD>
<TD style="HEIGHT: 28px">&nbsp;
<asp:TextBox id="tol" runat="server" Width="368px" TextMode="MultiLine" Height="187px"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 90px; HEIGHT: 164px" align="middle" colSpan="1" rowSpan="1">
<asp:Label id="Label4" runat="server" Font-Size="X-Small">图片上传</asp:Label></TD>
<TD style="HEIGHT: 164px">
<P>&nbsp; <INPUT style="WIDTH: 384px; HEIGHT: 22px" type="file" size="44" runat="server" id="fileup1"></P>
<P>&nbsp; <INPUT style="WIDTH: 384px; HEIGHT: 22px" type="file" size="44" runat="server" id="fileup2"></P>
<P>&nbsp; <INPUT style="WIDTH: 384px; HEIGHT: 22px" type="file" size="44" runat="server" id="fileup3"></P>
<P>&nbsp; <INPUT style="WIDTH: 385px; HEIGHT: 22px" type="file" size="45" runat="server" id="fileup4"></P>
</TD>
</TR>
<TR>
<TD style="WIDTH: 90px; HEIGHT: 39px" align="middle">
<asp:Label id="Label5" runat="server" Font-Size="X-Small">文件上传</asp:Label></TD>
<TD style="HEIGHT: 39px">&nbsp;</TD>
</TR>
<TR>
<TD style="WIDTH: 90px; HEIGHT: 33px" align="middle">
<asp:Label id="Label6" runat="server" Font-Size="X-Small">作者</asp:Label></TD>
<TD style="HEIGHT: 33px">&nbsp;
<asp:TextBox id="zuoze" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 90px; HEIGHT: 33px" align="middle">
<asp:Label id="Label7" runat="server" Font-Size="X-Small">来源</asp:Label></TD>
<TD style="HEIGHT: 33px">&nbsp;
<asp:TextBox id="laiyuan" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 90px; HEIGHT: 33px" align="middle">
<asp:Label id="Label8" runat="server" Font-Size="X-Small">时间</asp:Label></TD>
<TD style="HEIGHT: 33px">&nbsp;
<asp:TextBox id="shijian" runat="server"></asp:TextBox></TD>
</TR>
<TR>
<TD style="WIDTH: 90px" align="middle">
<asp:Label id="Label9" runat="server" Font-Size="X-Small">更新人</asp:Label></TD>
<TD>&nbsp;
<asp:TextBox id="TextBox6" runat="server"></asp:TextBox></TD>
</TR>
</TABLE>
<TABLE id="Table2" style="WIDTH: 190px; HEIGHT: 35px" cellSpacing="0" cellPadding="0" width="190" align="center" border="0">
<TR>
<TD align="middle">
<asp:Button id="Button1" runat="server" Width="68px" Text="提交"></asp:Button>&nbsp;
<asp:Button id="Button2" runat="server" Width="68px" Text="取消"></asp:Button></TD>
</TR>
</TABLE>
</FONT>
</form>
<FONT face="宋体"></FONT>
</body>
</HTML>

解决方案 »

  1.   

    Public Sub SavePhoto(ByVal sender As Object, ByVal e As EventArgs)        '取得所上传文件的长度
            Dim LenStr As Int32
            LenStr = photo.PostedFile.ContentLength        '取得上传图片的数据
            Dim streamStr As Stream
            streamStr = photo.PostedFile.InputStream        '设置缓冲区大小
            Dim imageBytes(LenStr) As Byte        '写入文件数据
            If photo.PostedFile.FileName = "" Then
                'alert("请选择一个文件名")            streamStr.Read(imageBytes, 0, LenStr)            Dim conn As New OleDb.OleDbConnection("server=127.0.0.1;database=zdsw1;password=111111;user id=zdsw")            Dim cmd As New OleDb.OleDbCommand("insert into Upload (image) values (@image)", conn)            cmd.Parameters.Add("@title", title.Value)
                cmd.Parameters.Add("@imageFile", imageBytes)            conn.Open()
                cmd.ExecuteNonQuery()
                Response.Write("成功")
                conn.Close()
                Response.End()
            End If
        End Sub
      

  2.   

    Dim i As Integer
            For i = 0 To Request.Files.Count - 1
                Dim postedfile As HttpPostedFile = Request.Files(i)
                If postedfile.ContentLength > 0 Then
                    '存储上传文件
                    Dim filesplit() As String = Split(postedfile.FileName, "\")
                    Dim filename As String = filesplit(filesplit.Length - 1)
                    postedfile.SaveAs(Server.MapPath("pic\") & filename)
                End If
            Next">"
      

  3.   

    If postedfile.ContentLength > 0 Then