Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > upload not working with small files? <4KB?

Thread Tools

upload not working with small files? <4KB?

Posts: n/a
I stumbled onto silimar posts and think I'm missing something here. I
reviewed the articles listed but am expericing an error when I go over
4KB??? I'm saving to SQl Server 2K, field is image. Nothing set in webconfig,
Any ideas?

Dim iLength As Integer = CType(inpFileUp.PostedFile.InputStream.Length,
If iLength = 0 Then Exit Sub 'not a valid file
Dim sContentType As String = inpFileUp.PostedFile.ContentType
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(iLength) 'byte array, set to file size

'strip the path off the filename
i = InStrRev(inpFileUp.PostedFile.FileName.Trim, "\")
If i = 0 Then
sFileName = inpFileUp.PostedFile.FileName.Trim
sFileName = Right(inpFileUp.PostedFile.FileName.Trim,
Len(inpFileUp.PostedFile.FileName.Trim) - i)
End If

inpFileUp.PostedFile.InputStream.Read(bytContent, 0, iLength)

Response.Write("filesize = " & iLength & "<br>")

'save new image record
Dim cmdInsert As New SqlCommand
Dim insertstring As String
Dim imageid As String

SqlConnect = New SqlConnection(ConnectString)

'add company info
insertstring = "INSERT tblImages ( Image_Name, Image_Filename,
Image_Type, Image_FileSize, Image, DateAdded, AddedBy ) VALUES ( @imagename,
@filename, @contenttype, @filesize, @image, @dateadded, @addedby );SELECT
@@Identity" 'using parameters

cmdInsert = New SqlCommand(insertstring, SqlConnect)

With cmdInsert

.Parameters.Add("@imagename", "" & txtimagetitle.Text)
.Parameters.Add("@filename", "" & sFileName)
.Parameters.Add("@contenttype", "" & sContentType)
.Parameters.Add("@filesize", iLength)
.Parameters.Add("@image", bytContent)
.Parameters.Add("@dateadded", Date.Now())
.Parameters.Add("@addedby", Session("contactid"))

End With

imageid = cmdInsert.ExecuteScalar

'close object and connection

'add new item to list
ddexistingimages.Items.Add(New ListItem(txtimagetitle.Text,

'set label for status
lblstatus.Text = "Image Saved"

Catch ex As Exception
'Handle your database error here

'set label for status
lblstatus.Text = "Error - Please Contact System Administrator."
'close object and connection
End Try

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Small javascript/html that's not working as I think it should - please help Javascript 1 10-26-2006 07:38 AM
Small cameras getting too small? GRL Digital Photography 50 02-03-2006 03:12 AM
Small Square with small red X Peter Coddington Computer Support 4 01-03-2006 06:58 AM
Re: upload image with small size ASP .Net 1 11-17-2005 10:35 AM
Why is this small Javascript not working ? Arthur Connor HTML 0 08-27-2003 08:07 AM