Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

upload not working with small files? <4KB?

 
 
=?Utf-8?B?Q2hyaXM=?=
Guest
Posts: n/a
 
      03-02-2005
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,
etc.
Any ideas?

Code:
Dim iLength As Integer = CType(inpFileUp.PostedFile.InputStream.Length,
Integer)
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
Else
sFileName = Right(inpFileUp.PostedFile.FileName.Trim,
Len(inpFileUp.PostedFile.FileName.Trim) - i)
End If

Try
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)
SqlConnect.Open()

'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
SqlConnect.Close()

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

'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
SqlConnect.Close()
End Try


 
Reply With Quote
 
 
 
Reply

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 gkellymail@gmail.com 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 sreejith.ram@gmail.com 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



Advertisments