Large File Upload Probelm...


G

Guest

Can someone please tell me why I keep getting an error saying the page cannot
be displayed in my ASP.NET app. If I upload a file that is under approx 3mb
then it works file but as soon as I try to upload a larger file I get

Page Cannot be displayed error...

I'm uploading the file as binary into and SQL 2000 Database!

Any advice would be appritiated!

Thanks

CODE::..
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

phBody.Controls.Add(New LiteralControl("<body bottomMargin=" &
Chr(34) & "0" & Chr(34) & "leftMargin=" & Chr(34) & "0" & Chr(34) &
"topMargin=" & Chr(34) & "0" & Chr(34) & "rightMargin=" & Chr(34) & "0" &
Chr(34) & "runat=" & Chr(34) & "server" & Chr(34) & ">"))

'Loads user controls
Dim c1 As Control = LoadControl("../userControls/footer.ascx")
phFooter.Controls.Add(c1)
Dim c2 As Control = LoadControl("../userControls/headerMenu.ascx")
phHeaderMenu.Controls.Add(c2)
Dim c3 As Control = LoadControl("../userControls/Header.ascx")
phHeader.Controls.Add(c3)
Dim c4 As Control = LoadControl("../userControls/QuickLinks.ascx")
phQuickLinks.Controls.Add(c4)

populateDDL()
UserDetails()

If Page.IsPostBack Then

' user submitted file to be uploaded
' create URL with query string to confirm file upload
' next page will not be a postback, so viewstate will be lost
Dim sRefreshURL As String = Request.Url.ToString() &
"?Upload=True"

If Request.Browser.Browser = "IE" Then
phBody.Controls.Clear()
phBody.Controls.Add(New LiteralControl("<body onload=" &
Chr(34) & "loadTarget(" & Chr(39) & sRefreshURL & Chr(39) & ")" & Chr(59) &
Chr(34) & " bottomMargin=" & Chr(34) & "0" & Chr(34) & " leftMargin=" &
Chr(34) & "0" & Chr(34) & " topMargin=" & Chr(34) & "0" & Chr(34) & "
rightMargin=" & Chr(34) & "0" & Chr(34) & " runat=" & Chr(34) & "server" &
Chr(34) & ">"))

' set META REFRESH as well in case script is disabled
' use long delay so that script can load page first if
possible
phRefresh.Controls.Clear()
phRefresh.Controls.Add(New LiteralControl("<meta
http-equiv=" & Chr(34) & "refresh" & Chr(34) & " content=" & Chr(34) &
"30;url=" & sRefreshURL & Chr(34) & ">"))
Else

' not IE so use META REFRESH to start loading next page
' allow 3 seconds for progress bar image to load

phRefresh.Controls.Clear()
phRefresh.Controls.Add(New LiteralControl("<meta
http-equiv=" & Chr(34) & "Refresh" & Chr(34) & " content=" & Chr(34) &
"3;url=" & sRefreshURL & Chr(34) & ">"))

End If

' hide Upload file controls and show "wait" section
pnlUploadFile.Visible = False
pnlWait.Visible = True
UploadData()

Else

' get query string
Dim iUpload As String = Request.QueryString("Upload")

If iUpload = "" Then

pnlUploadFile.Visible = True

Else
pnlUploadFile.Visible = False
pnlResults.Visible = True
lblResults.Text = "Your file has been succesfully uploaded..."

End If
Dim sRefreshURL As String = Request.Url.ToString() &
"?Upload=False"

End If

End Sub
Sub UploadData()
Dim imgstream As Stream = ImageFile.PostedFile.InputStream
Dim imgdata(ImageFile.PostedFile.ContentLength) As Byte
imgstream.Read(imgdata, 0, ImageFile.PostedFile.ContentLength)

Dim MyConn As New
SqlConnection(ConfigurationSettings.AppSettings("strConn"))
Dim cmd As New SqlCommand("fileUpload", MyConn)
cmd.CommandType = CommandType.StoredProcedure

Dim titleparam As New SqlParameter("@fileTitle", SqlDbType.NVarChar,
255)
Dim descriptionparam As New SqlParameter("@fileDescription",
SqlDbType.NVarChar, 255)
Dim Ownerparam As New SqlParameter("@fileOwner", SqlDbType.NVarChar,
255)
Dim Officeparam As New SqlParameter("@officeID", SqlDbType.Int)
Dim typeparam As New SqlParameter("@fileType", SqlDbType.NVarChar,
100)
Dim dataparam As New SqlParameter("@fileData", SqlDbType.Image)

titleparam.Value = ImageTitle.Text
descriptionparam.Value = fldDescription.Text
Ownerparam.Value = fldOwner.Text
Officeparam.Value = ddlOffice.SelectedIndex
typeparam.Value = ImageFile.PostedFile.ContentType
dataparam.Value = imgdata

cmd.Parameters.Add(titleparam)
cmd.Parameters.Add(descriptionparam)
cmd.Parameters.Add(Ownerparam)
cmd.Parameters.Add(Officeparam)
cmd.Parameters.Add(typeparam)
cmd.Parameters.Add(dataparam)

MyConn.Open()
cmd.ExecuteNonQuery()
MyConn.Close()
End Sub
 
Ad

Advertisements

Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Problems understanding User Control??? 4
User Control... HELP??? 3
USER CONTROL PROBLEMS... 0
USER CONTROL... ARHHHH 2
Progress Bar help 3
Problem with User Control... 2
Shared Sub 3

Top