I am facing problem in the code line "For Each postedFile As HttpPostedFile In FileUpload1.PostedFiles" there is an error occured is showing "PostedFile. .... is not a member of 'System.Web.UI.WebControls.FileUpload'." under FileUpload1.PostedFiles
Please help.
My code as below:
<div>
<asp:FileUpload ID="FileUp" runat="server" Multiple="Multiple"/>
</div>
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
For Each postedFile As HttpPostedFile In FileUp.PostedFiles
Dim filename As String = Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Using fs As Stream = postedFile.InputStream
Using br As New BinaryReader(fs)
Dim bytes As Byte() = br.ReadBytes(Convert.ToInt32(fs.Length))
Dim conndb As ConnectionClass = New ConnectionClass
Dim conString As String = conndb.getConString()
Using conn As New SqlConnection(constr)
Dim Sqlstr As String
If conn.State = ConnectionState.Open Then
conn.Close()
End If
conn.Open()
Sqlstr = "INSERT INTO Ads (img,word) values (@eimg,@word);"
Using cmd As SqlCommand = New SqlCommand(Sqlstr, conn)
cmd.Parameters.AddWithValue("@word", TBHeader.Text.ToString)
cmd.Parameters.AddWithValue("@eimg", imgByte)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Using
End Using
End Using
End Using
Next
Response.Redirect(Request.Url.AbsoluteUri)
End Sub