I am getting a terrible error and I don't know how to fix it. Can anyone give me any input?
Here is my code:
Dim strFileExtension As String
Dim strFileType As String
Dim intFileLen As Integer
Dim objStream As Stream
strFileType = fileUps.PostedFile.contenttype (error is here)
<input id="fileUps" Type="File" Runat="Server">Try something like:
Dim myFile As HttpPostedFile = fileUps.PostedFile
Dim nFileLen As Integer = myFile.ContentLengthIf nFileLen > 0 Then
Try
Dim myData(nFileLen) As Byte
myFile.InputStream.Read(myData, 0, nFileLen)
Dim strFilename As String = Path.GetFileName(myFile.FileName)
Dim newFile As FileStream = New FileStream(Server.MapPath("Imports\" & strFilename), FileMode.Create)
newFile.Write(Buffer, 0, Buffer.Length)
newFile.Close()
Catch ex As Ex as Exception
lblMsg.Text = "Failed to upload the file!"
End TryEnd If
MajorCats
Your code was very helpful, but I still receive the same error. I received the same error with
Dim nFileLen As integer = myFile.ContentLength
Do you recommend anything else?
0 comments:
Post a Comment