473,413 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

<INPUT = 'File'> upload problem

Hi, I am having a problem with an attachment system I made... it works with
files up to ~3MB in size then after that if you try to upload a file it just
goes to a "Page can not be displayed" page like it tried to do it but
errored... I thought changeing the max size for the file input box to about
100mb would fix it but nope

here is my page code and my code behind code...

==[html page]=============

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Attachments.aspx.vb" Inherits="SecureEmail.Attachments"%>
<%@ Register TagPrefix="cc1" Namespace="SecureEmail" Assembly="SecureEmail"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlTop" Src="../Themes/ctrlTop.ascx"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlBottom"
Src="../Themes/ctrlBottom.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlLeftSide"
Src="../Themes/ctrlLeftSide.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlRightSide"
Src="../Themes/ctrlRightSide.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Reschini Secure E-Mail Network</title>
<meta content="SharePoint.WebPartPage.Document" name="ProgId">
<meta content="full" name="WebPartPageExpansion">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table id="table1" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrltop id="CtrlTop1"
runat="server"></uc1:ctrltop></td>
</tr>
<tr>
<td vAlign="top" height="100%">
<table id="table2" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrlleftside id="CtrlLeftSide1"
runat="server"></uc1:ctrlleftside></td>
<td vAlign="top" width="100%">
<TABLE id="table4" cellSpacing="0" cellPadding="0" width="100%"
bgColor="#a0c6e5" border="0"
class="toolbar">
<TR>
<TD>
<p align="left"><asp:button id="btnOK" runat="server" Text="OK"
Font-Size="8pt"></asp:button>&nbsp;<asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
<table border="0" width="100%" id="table6" cellspacing="0"
cellpadding="0">
<tr>
<td>
<cc1:ctrlPageHeaderBox id="ctrlPageHeaderBox" runat="server"
Font-Size="8pt" AutoPostBack="True"
Text="Attachments"></cc1:ctrlPageHeaderBox></td>
</tr>
</table>
<table id="table3" cellPadding="0" width="100%" border="0">
<TBODY>
<tr>
<td><FONT face="Arial" size="1">Brows for an attachment using
the browse button, then
click add attachment to add it to the attachments
list.</FONT></td>
</tr>
<tr>
<td>&nbsp;<INPUT id="fileIn" type="file" name="fileIn"
runat="server">
<asp:Label id="lblErrorMsg" runat="server" Font-Size="8pt"
Font-Names="verdana" ForeColor="Red"></asp:Label>
<asp:customvalidator id="cvFile" runat="server" Font-Size="8pt"
ErrorMessage="Must specify a file"
Font-Names="Verdana"></asp:customvalidator></td>
</tr>
<tr>
<td>&nbsp;<FONT face="Arial" size="1">Current Attachments For
Message:</FONT></td>
</tr>
<tr>
<td><asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="0" width="350" id="table5" cellspacing="0"
cellpadding="5" style="border: 1px solid #A0C6E5">
<tr>
<td bgcolor="#A0C6E5" width="100%">
<font face="Arial" style="font-size:
8pt">Attachments</font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Size</span></font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Delete</span></font></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="100%" align="left">
<font size="2" face="Arial"><img border="0"
src="../images/attachfile.gif" width="17" height="13">
<%# DataBinder.Eval(Container.DataItem,"FileName")%>
</font>
</td>
<td nowrap align="right">
<font face="Arial" style="font-size: 8pt">
<%#
SecureEmail.Functions.FormatFileSize(DataBinder.Ev al(Container.DataItem,"Fil
eSize"))%>
</font>
</td>
<td nowrap align="center">
<a href='attachments.aspx?action=remove&id=<%#
DataBinder.Eval(Container.dataitem,"ID")%>'>
<img border="0" src="../images/delete.gif" width="16"
height="16"></a></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td width="100%" align="left" style="border-top: 1px solid
#A0C6E5">
<p align="right">
<font face="Arial" style="font-size: 8pt">Total</font>
</td>
<td nowrap align="right" style="border-top: 1px solid
#A0C6E5">
<font face="Arial" style="font-size: 8pt">0.05
MB</font></td>
<td nowrap align="center" style="border-top: 1px solid
#A0C6E5">&nbsp;</td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p>&nbsp;</p>
</td>
<td vAlign="top"><uc1:ctrlrightside id="CtrlRightSide1"
runat="server"></uc1:ctrlrightside></td>
</tr>
</table>
</TD></TR>
<tr>
<td vAlign="top"><uc1:ctrlbottom id="CtrlBottom1"
runat="server"></uc1:ctrlbottom></td>
</tr>
</TBODY></TABLE></form>
</body>
</HTML>


================================================== ==========================
=====
==== Code Behind ================================================== =========
Public Class Attachments

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Protected WithEvents btnOK As System.Web.UI.WebControls.Button

Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater

Protected WithEvents fileIn As System.Web.UI.HtmlControls.HtmlInputFile

Protected WithEvents btnAddAttachment As System.Web.UI.WebControls.Button

Protected WithEvents cvFile As System.Web.UI.WebControls.CustomValidator

Protected WithEvents ctrlPageHeaderBox As SecureEmail.ctrlPageHeaderBox

Protected WithEvents lblErrorMsg As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

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

If Not IsPostBack Then

' if there isn't an attachments table already...

If Session("AttachmentsTable") Is Nothing Then

' get schema from db and create a table from it...

Dim dt_attachments As New DataTable

dt_attachments.Columns.Add(New DataColumn("FileName", GetType(String)))

dt_attachments.Columns.Add(New DataColumn("FileSize", GetType(Int32)))

Dim dc_ID As DataColumn = dt_attachments.Columns.Add("ID", GetType(Integer))

dc_ID.AutoIncrement = True

dc_ID.AutoIncrementSeed = 1

dc_ID.AutoIncrementStep = 2

dc_ID.ReadOnly = True

dt_attachments.PrimaryKey = New DataColumn() {dt_attachments.Columns("ID")}

dt_attachments.Columns.Add(New DataColumn("AttachmentData",
GetType(Byte())))

Session("AttachmentsTable") = dt_attachments

End If

If Not Request.QueryString("action") Is Nothing Then

Select Case Request.QueryString("action").ToLower

Case "remove"

Dim DR_ROW As DataRow

DR_ROW = DirectCast(Session("AttachmentsTable"),
DataTable).Rows.Find(Convert.ToInt32(Request.Query String("ID")))

DR_ROW.Delete()

End Select

End If

End If

Me.Repeater1.DataSource = Session("AttachmentsTable")

Me.Repeater1.DataBind()

End Sub

Private Sub AddAttachment()

If Me.fileIn.Value.Trim.Length = 0 Then

Me.cvFile.IsValid = False

Else

Try

Me.lblErrorMsg.Visible = False

Dim AttachedFileCollection As HttpFileCollection

Dim a As HtmlInputFile

Me.fileIn.MaxLength = (100 * 1024) ' 100 MB upload max

Dim MyFile As HttpPostedFile

Dim FileLength As Integer

Dim FileName As String

Dim FileStream As System.IO.Stream

AttachedFileCollection = Request.Files

MyFile = AttachedFileCollection(0)

FileLength = MyFile.ContentLength

Dim FileData(FileLength) As Byte

FileStream = MyFile.InputStream

FileStream.Read(FileData, 0, FileLength)

Me.cvFile.IsValid = True

Dim dr_row As DataRow = DirectCast(Session("AttachmentsTable"),
DataTable).NewRow

dr_row("FileName") = IO.Path.GetFileName(MyFile.FileName).ToUpper

dr_row("FileSize") = MyFile.ContentLength

dr_row("AttachmentData") = FileData

DirectCast(Session("AttachmentsTable"), DataTable).Rows.Add(dr_row)

Catch ex As Exception

Me.lblErrorMsg.Visible = True

Me.lblErrorMsg.Text = "Error uploading file: " & ex.Message

End Try

Me.Repeater1.DataBind()

End If

End Sub

Private Sub btnAddAttachment_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAddAttachment.Click

AddAttachment()

End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

Response.Redirect("Compose.aspx")

End Sub

End Class
Nov 18 '05 #1
10 3052
Have you checked to see if the page is timing out before the upload is
complete?

--
----------------------------------------------------------------
-**-
www.byteboss.com : EZ website builder
-**-
Replace the Z with the e to reply
----------------------------------------------------------------

"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:eW*************@TK2MSFTNGP12.phx.gbl...
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page like it tried to do it but
errored... I thought changeing the max size for the file input box to about 100mb would fix it but nope

here is my page code and my code behind code...

==[html page]=============

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Attachments.aspx.vb" Inherits="SecureEmail.Attachments"%>
<%@ Register TagPrefix="cc1" Namespace="SecureEmail" Assembly="SecureEmail" %>
<%@ Register TagPrefix="uc1" TagName="ctrlTop" Src="../Themes/ctrlTop.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlBottom"
Src="../Themes/ctrlBottom.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlLeftSide"
Src="../Themes/ctrlLeftSide.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlRightSide"
Src="../Themes/ctrlRightSide.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Reschini Secure E-Mail Network</title>
<meta content="SharePoint.WebPartPage.Document" name="ProgId">
<meta content="full" name="WebPartPageExpansion">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table id="table1" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrltop id="CtrlTop1"
runat="server"></uc1:ctrltop></td>
</tr>
<tr>
<td vAlign="top" height="100%">
<table id="table2" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrlleftside id="CtrlLeftSide1"
runat="server"></uc1:ctrlleftside></td>
<td vAlign="top" width="100%">
<TABLE id="table4" cellSpacing="0" cellPadding="0" width="100%"
bgColor="#a0c6e5" border="0"
class="toolbar">
<TR>
<TD>
<p align="left"><asp:button id="btnOK" runat="server" Text="OK" Font-Size="8pt"></asp:button>&nbsp;<asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
<table border="0" width="100%" id="table6" cellspacing="0"
cellpadding="0">
<tr>
<td>
<cc1:ctrlPageHeaderBox id="ctrlPageHeaderBox" runat="server"
Font-Size="8pt" AutoPostBack="True"
Text="Attachments"></cc1:ctrlPageHeaderBox></td>
</tr>
</table>
<table id="table3" cellPadding="0" width="100%" border="0">
<TBODY>
<tr>
<td><FONT face="Arial" size="1">Brows for an attachment using
the browse button, then
click add attachment to add it to the attachments
list.</FONT></td>
</tr>
<tr>
<td>&nbsp;<INPUT id="fileIn" type="file" name="fileIn"
runat="server">
<asp:Label id="lblErrorMsg" runat="server" Font-Size="8pt"
Font-Names="verdana" ForeColor="Red"></asp:Label>
<asp:customvalidator id="cvFile" runat="server" Font-Size="8pt" ErrorMessage="Must specify a file"
Font-Names="Verdana"></asp:customvalidator></td>
</tr>
<tr>
<td>&nbsp;<FONT face="Arial" size="1">Current Attachments For
Message:</FONT></td>
</tr>
<tr>
<td><asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="0" width="350" id="table5" cellspacing="0"
cellpadding="5" style="border: 1px solid #A0C6E5">
<tr>
<td bgcolor="#A0C6E5" width="100%">
<font face="Arial" style="font-size:
8pt">Attachments</font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Size</span></font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Delete</span></font></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="100%" align="left">
<font size="2" face="Arial"><img border="0"
src="../images/attachfile.gif" width="17" height="13">
<%# DataBinder.Eval(Container.DataItem,"FileName")%>
</font>
</td>
<td nowrap align="right">
<font face="Arial" style="font-size: 8pt">
<%#
SecureEmail.Functions.FormatFileSize(DataBinder.Ev al(Container.DataItem,"Fil eSize"))%>
</font>
</td>
<td nowrap align="center">
<a href='attachments.aspx?action=remove&id=<%#
DataBinder.Eval(Container.dataitem,"ID")%>'>
<img border="0" src="../images/delete.gif" width="16"
height="16"></a></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td width="100%" align="left" style="border-top: 1px solid
#A0C6E5">
<p align="right">
<font face="Arial" style="font-size: 8pt">Total</font>
</td>
<td nowrap align="right" style="border-top: 1px solid
#A0C6E5">
<font face="Arial" style="font-size: 8pt">0.05
MB</font></td>
<td nowrap align="center" style="border-top: 1px solid
#A0C6E5">&nbsp;</td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p>&nbsp;</p>
</td>
<td vAlign="top"><uc1:ctrlrightside id="CtrlRightSide1"
runat="server"></uc1:ctrlrightside></td>
</tr>
</table>
</TD></TR>
<tr>
<td vAlign="top"><uc1:ctrlbottom id="CtrlBottom1"
runat="server"></uc1:ctrlbottom></td>
</tr>
</TBODY></TABLE></form>
</body>
</HTML>


================================================== ========================== =====
==== Code Behind ================================================== =========

Public Class Attachments

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub

Protected WithEvents btnOK As System.Web.UI.WebControls.Button

Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater

Protected WithEvents fileIn As System.Web.UI.HtmlControls.HtmlInputFile

Protected WithEvents btnAddAttachment As System.Web.UI.WebControls.Button

Protected WithEvents cvFile As System.Web.UI.WebControls.CustomValidator

Protected WithEvents ctrlPageHeaderBox As SecureEmail.ctrlPageHeaderBox

Protected WithEvents lblErrorMsg As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

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

If Not IsPostBack Then

' if there isn't an attachments table already...

If Session("AttachmentsTable") Is Nothing Then

' get schema from db and create a table from it...

Dim dt_attachments As New DataTable

dt_attachments.Columns.Add(New DataColumn("FileName", GetType(String)))

dt_attachments.Columns.Add(New DataColumn("FileSize", GetType(Int32)))

Dim dc_ID As DataColumn = dt_attachments.Columns.Add("ID", GetType(Integer))
dc_ID.AutoIncrement = True

dc_ID.AutoIncrementSeed = 1

dc_ID.AutoIncrementStep = 2

dc_ID.ReadOnly = True

dt_attachments.PrimaryKey = New DataColumn() {dt_attachments.Columns("ID")}
dt_attachments.Columns.Add(New DataColumn("AttachmentData",
GetType(Byte())))

Session("AttachmentsTable") = dt_attachments

End If

If Not Request.QueryString("action") Is Nothing Then

Select Case Request.QueryString("action").ToLower

Case "remove"

Dim DR_ROW As DataRow

DR_ROW = DirectCast(Session("AttachmentsTable"),
DataTable).Rows.Find(Convert.ToInt32(Request.Query String("ID")))

DR_ROW.Delete()

End Select

End If

End If

Me.Repeater1.DataSource = Session("AttachmentsTable")

Me.Repeater1.DataBind()

End Sub

Private Sub AddAttachment()

If Me.fileIn.Value.Trim.Length = 0 Then

Me.cvFile.IsValid = False

Else

Try

Me.lblErrorMsg.Visible = False

Dim AttachedFileCollection As HttpFileCollection

Dim a As HtmlInputFile

Me.fileIn.MaxLength = (100 * 1024) ' 100 MB upload max

Dim MyFile As HttpPostedFile

Dim FileLength As Integer

Dim FileName As String

Dim FileStream As System.IO.Stream

AttachedFileCollection = Request.Files

MyFile = AttachedFileCollection(0)

FileLength = MyFile.ContentLength

Dim FileData(FileLength) As Byte

FileStream = MyFile.InputStream

FileStream.Read(FileData, 0, FileLength)

Me.cvFile.IsValid = True

Dim dr_row As DataRow = DirectCast(Session("AttachmentsTable"),
DataTable).NewRow

dr_row("FileName") = IO.Path.GetFileName(MyFile.FileName).ToUpper

dr_row("FileSize") = MyFile.ContentLength

dr_row("AttachmentData") = FileData

DirectCast(Session("AttachmentsTable"), DataTable).Rows.Add(dr_row)

Catch ex As Exception

Me.lblErrorMsg.Visible = True

Me.lblErrorMsg.Text = "Error uploading file: " & ex.Message

End Try

Me.Repeater1.DataBind()

End If

End Sub

Private Sub btnAddAttachment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddAttachment.Click

AddAttachment()

End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

Response.Redirect("Compose.aspx")

End Sub

End Class

Nov 18 '05 #2
this happens instantaniously... soon as i click on the attach button, it
goes straight to the page can not be displayed page... where can i look at
time out settings though?
"Mark" <ma**@Z-Zvolution.nZt> wrote in message
news:cd**********@lust.ihug.co.nz...
Have you checked to see if the page is timing out before the upload is
complete?

--
----------------------------------------------------------------
-**-
www.byteboss.com : EZ website builder
-**-
Replace the Z with the e to reply
----------------------------------------------------------------

"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:eW*************@TK2MSFTNGP12.phx.gbl...
Hi, I am having a problem with an attachment system I made... it works with
files up to ~3MB in size then after that if you try to upload a file it

just
goes to a "Page can not be displayed" page like it tried to do it but
errored... I thought changeing the max size for the file input box to

about
100mb would fix it but nope

here is my page code and my code behind code...

==[html page]=============

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Attachments.aspx.vb" Inherits="SecureEmail.Attachments"%>
<%@ Register TagPrefix="cc1" Namespace="SecureEmail"

Assembly="SecureEmail"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlTop"

Src="../Themes/ctrlTop.ascx"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlBottom"
Src="../Themes/ctrlBottom.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlLeftSide"
Src="../Themes/ctrlLeftSide.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlRightSide"
Src="../Themes/ctrlRightSide.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Reschini Secure E-Mail Network</title>
<meta content="SharePoint.WebPartPage.Document" name="ProgId">
<meta content="full" name="WebPartPageExpansion">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table id="table1" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrltop id="CtrlTop1"
runat="server"></uc1:ctrltop></td>
</tr>
<tr>
<td vAlign="top" height="100%">
<table id="table2" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrlleftside id="CtrlLeftSide1"
runat="server"></uc1:ctrlleftside></td>
<td vAlign="top" width="100%">
<TABLE id="table4" cellSpacing="0" cellPadding="0" width="100%"
bgColor="#a0c6e5" border="0"
class="toolbar">
<TR>
<TD>
<p align="left"><asp:button id="btnOK" runat="server"

Text="OK"
Font-Size="8pt"></asp:button>&nbsp;<asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
<table border="0" width="100%" id="table6" cellspacing="0"
cellpadding="0">
<tr>
<td>
<cc1:ctrlPageHeaderBox id="ctrlPageHeaderBox" runat="server"
Font-Size="8pt" AutoPostBack="True"
Text="Attachments"></cc1:ctrlPageHeaderBox></td>
</tr>
</table>
<table id="table3" cellPadding="0" width="100%" border="0">
<TBODY>
<tr>
<td><FONT face="Arial" size="1">Brows for an attachment using the browse button, then
click add attachment to add it to the attachments
list.</FONT></td>
</tr>
<tr>
<td>&nbsp;<INPUT id="fileIn" type="file" name="fileIn"
runat="server">
<asp:Label id="lblErrorMsg" runat="server" Font-Size="8pt"
Font-Names="verdana" ForeColor="Red"></asp:Label>
<asp:customvalidator id="cvFile" runat="server"

Font-Size="8pt"
ErrorMessage="Must specify a file"
Font-Names="Verdana"></asp:customvalidator></td>
</tr>
<tr>
<td>&nbsp;<FONT face="Arial" size="1">Current Attachments For Message:</FONT></td>
</tr>
<tr>
<td><asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="0" width="350" id="table5" cellspacing="0"
cellpadding="5" style="border: 1px solid #A0C6E5">
<tr>
<td bgcolor="#A0C6E5" width="100%">
<font face="Arial" style="font-size:
8pt">Attachments</font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Size</span></font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Delete</span></font></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="100%" align="left">
<font size="2" face="Arial"><img border="0"
src="../images/attachfile.gif" width="17" height="13">
<%# DataBinder.Eval(Container.DataItem,"FileName")%>
</font>
</td>
<td nowrap align="right">
<font face="Arial" style="font-size: 8pt">
<%#

SecureEmail.Functions.FormatFileSize(DataBinder.Ev al(Container.DataItem,"Fil
eSize"))%>
</font>
</td>
<td nowrap align="center">
<a href='attachments.aspx?action=remove&id=<%#
DataBinder.Eval(Container.dataitem,"ID")%>'>
<img border="0" src="../images/delete.gif" width="16"
height="16"></a></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td width="100%" align="left" style="border-top: 1px solid #A0C6E5">
<p align="right">
<font face="Arial" style="font-size: 8pt">Total</font>
</td>
<td nowrap align="right" style="border-top: 1px solid
#A0C6E5">
<font face="Arial" style="font-size: 8pt">0.05
MB</font></td>
<td nowrap align="center" style="border-top: 1px solid
#A0C6E5">&nbsp;</td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p>&nbsp;</p>
</td>
<td vAlign="top"><uc1:ctrlrightside id="CtrlRightSide1"
runat="server"></uc1:ctrlrightside></td>
</tr>
</table>
</TD></TR>
<tr>
<td vAlign="top"><uc1:ctrlbottom id="CtrlBottom1"
runat="server"></uc1:ctrlbottom></td>
</tr>
</TBODY></TABLE></form>
</body>
</HTML>


================================================== ==========================
=====
==== Code Behind

================================================== =========


Public Class Attachments

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub

InitializeComponent()

End Sub

Protected WithEvents btnOK As System.Web.UI.WebControls.Button

Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater

Protected WithEvents fileIn As System.Web.UI.HtmlControls.HtmlInputFile

Protected WithEvents btnAddAttachment As System.Web.UI.WebControls.Button
Protected WithEvents cvFile As System.Web.UI.WebControls.CustomValidator

Protected WithEvents ctrlPageHeaderBox As SecureEmail.ctrlPageHeaderBox

Protected WithEvents lblErrorMsg As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

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

If Not IsPostBack Then

' if there isn't an attachments table already...

If Session("AttachmentsTable") Is Nothing Then

' get schema from db and create a table from it...

Dim dt_attachments As New DataTable

dt_attachments.Columns.Add(New DataColumn("FileName", GetType(String)))

dt_attachments.Columns.Add(New DataColumn("FileSize", GetType(Int32)))

Dim dc_ID As DataColumn = dt_attachments.Columns.Add("ID",

GetType(Integer))

dc_ID.AutoIncrement = True

dc_ID.AutoIncrementSeed = 1

dc_ID.AutoIncrementStep = 2

dc_ID.ReadOnly = True

dt_attachments.PrimaryKey = New DataColumn()

{dt_attachments.Columns("ID")}

dt_attachments.Columns.Add(New DataColumn("AttachmentData",
GetType(Byte())))

Session("AttachmentsTable") = dt_attachments

End If

If Not Request.QueryString("action") Is Nothing Then

Select Case Request.QueryString("action").ToLower

Case "remove"

Dim DR_ROW As DataRow

DR_ROW = DirectCast(Session("AttachmentsTable"),
DataTable).Rows.Find(Convert.ToInt32(Request.Query String("ID")))

DR_ROW.Delete()

End Select

End If

End If

Me.Repeater1.DataSource = Session("AttachmentsTable")

Me.Repeater1.DataBind()

End Sub

Private Sub AddAttachment()

If Me.fileIn.Value.Trim.Length = 0 Then

Me.cvFile.IsValid = False

Else

Try

Me.lblErrorMsg.Visible = False

Dim AttachedFileCollection As HttpFileCollection

Dim a As HtmlInputFile

Me.fileIn.MaxLength = (100 * 1024) ' 100 MB upload max

Dim MyFile As HttpPostedFile

Dim FileLength As Integer

Dim FileName As String

Dim FileStream As System.IO.Stream

AttachedFileCollection = Request.Files

MyFile = AttachedFileCollection(0)

FileLength = MyFile.ContentLength

Dim FileData(FileLength) As Byte

FileStream = MyFile.InputStream

FileStream.Read(FileData, 0, FileLength)

Me.cvFile.IsValid = True

Dim dr_row As DataRow = DirectCast(Session("AttachmentsTable"),
DataTable).NewRow

dr_row("FileName") = IO.Path.GetFileName(MyFile.FileName).ToUpper

dr_row("FileSize") = MyFile.ContentLength

dr_row("AttachmentData") = FileData

DirectCast(Session("AttachmentsTable"), DataTable).Rows.Add(dr_row)

Catch ex As Exception

Me.lblErrorMsg.Visible = True

Me.lblErrorMsg.Text = "Error uploading file: " & ex.Message

End Try

Me.Repeater1.DataBind()

End If

End Sub

Private Sub btnAddAttachment_Click(ByVal sender As System.Object, ByVal

e As
System.EventArgs) Handles btnAddAttachment.Click

AddAttachment()

End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

Response.Redirect("Compose.aspx")

End Sub

End Class


Nov 18 '05 #3
On Tue, 20 Jul 2004 15:14:16 -0400, "Brian Henry"
<br**********@newsgroups.nospam> wrote:
Hi, I am having a problem with an attachment system I made... it works with
files up to ~3MB in size then after that if you try to upload a file it just
goes to a "Page can not be displayed" page like it tried to do it but
errored... I thought changeing the max size for the file input box to about
100mb would fix it but nope

here is my page code and my code behind code...


Try this first:
http://support.microsoft.com/default...b;EN-US;295626

"~3MB" is close enough to 4MB, the default limit.

--
Chris
ne***************@netchris.com
Nov 18 '05 #4
You can add or modify the following section in your web.config file:

<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" />
</system.web>
</configuration>

The above value (4096 KB) is the default maximum upload file size.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:eW*************@TK2MSFTNGP12.phx.gbl...
Hi, I am having a problem with an attachment system I made... it works with files up to ~3MB in size then after that if you try to upload a file it just goes to a "Page can not be displayed" page like it tried to do it but
errored... I thought changeing the max size for the file input box to about 100mb would fix it but nope

here is my page code and my code behind code...

==[html page]=============

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Attachments.aspx.vb" Inherits="SecureEmail.Attachments"%>
<%@ Register TagPrefix="cc1" Namespace="SecureEmail" Assembly="SecureEmail" %>
<%@ Register TagPrefix="uc1" TagName="ctrlTop" Src="../Themes/ctrlTop.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlBottom"
Src="../Themes/ctrlBottom.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlLeftSide"
Src="../Themes/ctrlLeftSide.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlRightSide"
Src="../Themes/ctrlRightSide.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Reschini Secure E-Mail Network</title>
<meta content="SharePoint.WebPartPage.Document" name="ProgId">
<meta content="full" name="WebPartPageExpansion">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table id="table1" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrltop id="CtrlTop1"
runat="server"></uc1:ctrltop></td>
</tr>
<tr>
<td vAlign="top" height="100%">
<table id="table2" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrlleftside id="CtrlLeftSide1"
runat="server"></uc1:ctrlleftside></td>
<td vAlign="top" width="100%">
<TABLE id="table4" cellSpacing="0" cellPadding="0" width="100%"
bgColor="#a0c6e5" border="0"
class="toolbar">
<TR>
<TD>
<p align="left"><asp:button id="btnOK" runat="server" Text="OK" Font-Size="8pt"></asp:button>&nbsp;<asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
<table border="0" width="100%" id="table6" cellspacing="0"
cellpadding="0">
<tr>
<td>
<cc1:ctrlPageHeaderBox id="ctrlPageHeaderBox" runat="server"
Font-Size="8pt" AutoPostBack="True"
Text="Attachments"></cc1:ctrlPageHeaderBox></td>
</tr>
</table>
<table id="table3" cellPadding="0" width="100%" border="0">
<TBODY>
<tr>
<td><FONT face="Arial" size="1">Brows for an attachment using
the browse button, then
click add attachment to add it to the attachments
list.</FONT></td>
</tr>
<tr>
<td>&nbsp;<INPUT id="fileIn" type="file" name="fileIn"
runat="server">
<asp:Label id="lblErrorMsg" runat="server" Font-Size="8pt"
Font-Names="verdana" ForeColor="Red"></asp:Label>
<asp:customvalidator id="cvFile" runat="server" Font-Size="8pt" ErrorMessage="Must specify a file"
Font-Names="Verdana"></asp:customvalidator></td>
</tr>
<tr>
<td>&nbsp;<FONT face="Arial" size="1">Current Attachments For
Message:</FONT></td>
</tr>
<tr>
<td><asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="0" width="350" id="table5" cellspacing="0"
cellpadding="5" style="border: 1px solid #A0C6E5">
<tr>
<td bgcolor="#A0C6E5" width="100%">
<font face="Arial" style="font-size:
8pt">Attachments</font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Size</span></font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Delete</span></font></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="100%" align="left">
<font size="2" face="Arial"><img border="0"
src="../images/attachfile.gif" width="17" height="13">
<%# DataBinder.Eval(Container.DataItem,"FileName")%>
</font>
</td>
<td nowrap align="right">
<font face="Arial" style="font-size: 8pt">
<%#
SecureEmail.Functions.FormatFileSize(DataBinder.Ev al(Container.DataItem,"Fil eSize"))%>
</font>
</td>
<td nowrap align="center">
<a href='attachments.aspx?action=remove&id=<%#
DataBinder.Eval(Container.dataitem,"ID")%>'>
<img border="0" src="../images/delete.gif" width="16"
height="16"></a></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td width="100%" align="left" style="border-top: 1px solid
#A0C6E5">
<p align="right">
<font face="Arial" style="font-size: 8pt">Total</font>
</td>
<td nowrap align="right" style="border-top: 1px solid
#A0C6E5">
<font face="Arial" style="font-size: 8pt">0.05
MB</font></td>
<td nowrap align="center" style="border-top: 1px solid
#A0C6E5">&nbsp;</td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p>&nbsp;</p>
</td>
<td vAlign="top"><uc1:ctrlrightside id="CtrlRightSide1"
runat="server"></uc1:ctrlrightside></td>
</tr>
</table>
</TD></TR>
<tr>
<td vAlign="top"><uc1:ctrlbottom id="CtrlBottom1"
runat="server"></uc1:ctrlbottom></td>
</tr>
</TBODY></TABLE></form>
</body>
</HTML>


================================================== ========================== =====
==== Code Behind ================================================== =========

Public Class Attachments

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub

Protected WithEvents btnOK As System.Web.UI.WebControls.Button

Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater

Protected WithEvents fileIn As System.Web.UI.HtmlControls.HtmlInputFile

Protected WithEvents btnAddAttachment As System.Web.UI.WebControls.Button

Protected WithEvents cvFile As System.Web.UI.WebControls.CustomValidator

Protected WithEvents ctrlPageHeaderBox As SecureEmail.ctrlPageHeaderBox

Protected WithEvents lblErrorMsg As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

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

If Not IsPostBack Then

' if there isn't an attachments table already...

If Session("AttachmentsTable") Is Nothing Then

' get schema from db and create a table from it...

Dim dt_attachments As New DataTable

dt_attachments.Columns.Add(New DataColumn("FileName", GetType(String)))

dt_attachments.Columns.Add(New DataColumn("FileSize", GetType(Int32)))

Dim dc_ID As DataColumn = dt_attachments.Columns.Add("ID", GetType(Integer))
dc_ID.AutoIncrement = True

dc_ID.AutoIncrementSeed = 1

dc_ID.AutoIncrementStep = 2

dc_ID.ReadOnly = True

dt_attachments.PrimaryKey = New DataColumn() {dt_attachments.Columns("ID")}
dt_attachments.Columns.Add(New DataColumn("AttachmentData",
GetType(Byte())))

Session("AttachmentsTable") = dt_attachments

End If

If Not Request.QueryString("action") Is Nothing Then

Select Case Request.QueryString("action").ToLower

Case "remove"

Dim DR_ROW As DataRow

DR_ROW = DirectCast(Session("AttachmentsTable"),
DataTable).Rows.Find(Convert.ToInt32(Request.Query String("ID")))

DR_ROW.Delete()

End Select

End If

End If

Me.Repeater1.DataSource = Session("AttachmentsTable")

Me.Repeater1.DataBind()

End Sub

Private Sub AddAttachment()

If Me.fileIn.Value.Trim.Length = 0 Then

Me.cvFile.IsValid = False

Else

Try

Me.lblErrorMsg.Visible = False

Dim AttachedFileCollection As HttpFileCollection

Dim a As HtmlInputFile

Me.fileIn.MaxLength = (100 * 1024) ' 100 MB upload max

Dim MyFile As HttpPostedFile

Dim FileLength As Integer

Dim FileName As String

Dim FileStream As System.IO.Stream

AttachedFileCollection = Request.Files

MyFile = AttachedFileCollection(0)

FileLength = MyFile.ContentLength

Dim FileData(FileLength) As Byte

FileStream = MyFile.InputStream

FileStream.Read(FileData, 0, FileLength)

Me.cvFile.IsValid = True

Dim dr_row As DataRow = DirectCast(Session("AttachmentsTable"),
DataTable).NewRow

dr_row("FileName") = IO.Path.GetFileName(MyFile.FileName).ToUpper

dr_row("FileSize") = MyFile.ContentLength

dr_row("AttachmentData") = FileData

DirectCast(Session("AttachmentsTable"), DataTable).Rows.Add(dr_row)

Catch ex As Exception

Me.lblErrorMsg.Visible = True

Me.lblErrorMsg.Text = "Error uploading file: " & ex.Message

End Try

Me.Repeater1.DataBind()

End If

End Sub

Private Sub btnAddAttachment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddAttachment.Click

AddAttachment()

End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

Response.Redirect("Compose.aspx")

End Sub

End Class

Nov 18 '05 #5
Hi Brian,

I've noticed that there is another post on the <input type=file> html
control you've posted in this group, yes? Are they focus on the same issue?
As the other members have mentioned, the "maxRequestLength" attribute will
limit the max length file that can be uploaded and the default is 4MB.
Also, I suggest that you have a look at the following tech article I've
mentioned in another thread:

#Uploading Files Using the File Field Control
http://msdn.microsoft.com/library/en...eupload.asp?fr
ame=true#aspnet-fileupload_topic2c

If you have anything unclear or any other findings, please feel free to
post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #6
yep, turns out the were a related problem thanks

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Bn**************@cpmsftngxa06.phx.gbl...
Hi Brian,

I've noticed that there is another post on the <input type=file> html
control you've posted in this group, yes? Are they focus on the same issue? As the other members have mentioned, the "maxRequestLength" attribute will
limit the max length file that can be uploaded and the default is 4MB.
Also, I suggest that you have a look at the following tech article I've
mentioned in another thread:

#Uploading Files Using the File Field Control
http://msdn.microsoft.com/library/en...eupload.asp?fr ame=true#aspnet-fileupload_topic2c

If you have anything unclear or any other findings, please feel free to
post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #7
that fixed it thanks!
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:e5**************@tk2msftngp13.phx.gbl...
You can add or modify the following section in your web.config file:

<configuration>
<system.web>
<httpRuntime maxRequestLength="4096" />
</system.web>
</configuration>

The above value (4096 KB) is the default maximum upload file size.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

"Brian Henry" <br**********@newsgroups.nospam> wrote in message
news:eW*************@TK2MSFTNGP12.phx.gbl...
Hi, I am having a problem with an attachment system I made... it works with
files up to ~3MB in size then after that if you try to upload a file it

just
goes to a "Page can not be displayed" page like it tried to do it but
errored... I thought changeing the max size for the file input box to

about
100mb would fix it but nope

here is my page code and my code behind code...

==[html page]=============

<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="Attachments.aspx.vb" Inherits="SecureEmail.Attachments"%>
<%@ Register TagPrefix="cc1" Namespace="SecureEmail"

Assembly="SecureEmail"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlTop"

Src="../Themes/ctrlTop.ascx"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlBottom"
Src="../Themes/ctrlBottom.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlLeftSide"
Src="../Themes/ctrlLeftSide.ascx" %>
<%@ Register TagPrefix="uc1" TagName="ctrlRightSide"
Src="../Themes/ctrlRightSide.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Reschini Secure E-Mail Network</title>
<meta content="SharePoint.WebPartPage.Document" name="ProgId">
<meta content="full" name="WebPartPageExpansion">
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0"
MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<table id="table1" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrltop id="CtrlTop1"
runat="server"></uc1:ctrltop></td>
</tr>
<tr>
<td vAlign="top" height="100%">
<table id="table2" height="100%" cellSpacing="0" cellPadding="0"
width="100%" border="0">
<tr>
<td vAlign="top"><uc1:ctrlleftside id="CtrlLeftSide1"
runat="server"></uc1:ctrlleftside></td>
<td vAlign="top" width="100%">
<TABLE id="table4" cellSpacing="0" cellPadding="0" width="100%"
bgColor="#a0c6e5" border="0"
class="toolbar">
<TR>
<TD>
<p align="left"><asp:button id="btnOK" runat="server"

Text="OK"
Font-Size="8pt"></asp:button>&nbsp;<asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD>&nbsp;</TD>
</TR>
</TABLE>
<table border="0" width="100%" id="table6" cellspacing="0"
cellpadding="0">
<tr>
<td>
<cc1:ctrlPageHeaderBox id="ctrlPageHeaderBox" runat="server"
Font-Size="8pt" AutoPostBack="True"
Text="Attachments"></cc1:ctrlPageHeaderBox></td>
</tr>
</table>
<table id="table3" cellPadding="0" width="100%" border="0">
<TBODY>
<tr>
<td><FONT face="Arial" size="1">Brows for an attachment using the browse button, then
click add attachment to add it to the attachments
list.</FONT></td>
</tr>
<tr>
<td>&nbsp;<INPUT id="fileIn" type="file" name="fileIn"
runat="server">
<asp:Label id="lblErrorMsg" runat="server" Font-Size="8pt"
Font-Names="verdana" ForeColor="Red"></asp:Label>
<asp:customvalidator id="cvFile" runat="server"

Font-Size="8pt"
ErrorMessage="Must specify a file"
Font-Names="Verdana"></asp:customvalidator></td>
</tr>
<tr>
<td>&nbsp;<FONT face="Arial" size="1">Current Attachments For Message:</FONT></td>
</tr>
<tr>
<td><asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="0" width="350" id="table5" cellspacing="0"
cellpadding="5" style="border: 1px solid #A0C6E5">
<tr>
<td bgcolor="#A0C6E5" width="100%">
<font face="Arial" style="font-size:
8pt">Attachments</font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Size</span></font></td>
<td bgcolor="#A0C6E5" nowrap>
<font face="Arial"><span style="font-size:
8pt">Delete</span></font></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="100%" align="left">
<font size="2" face="Arial"><img border="0"
src="../images/attachfile.gif" width="17" height="13">
<%# DataBinder.Eval(Container.DataItem,"FileName")%>
</font>
</td>
<td nowrap align="right">
<font face="Arial" style="font-size: 8pt">
<%#

SecureEmail.Functions.FormatFileSize(DataBinder.Ev al(Container.DataItem,"Fil
eSize"))%>
</font>
</td>
<td nowrap align="center">
<a href='attachments.aspx?action=remove&id=<%#
DataBinder.Eval(Container.dataitem,"ID")%>'>
<img border="0" src="../images/delete.gif" width="16"
height="16"></a></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td width="100%" align="left" style="border-top: 1px solid #A0C6E5">
<p align="right">
<font face="Arial" style="font-size: 8pt">Total</font>
</td>
<td nowrap align="right" style="border-top: 1px solid
#A0C6E5">
<font face="Arial" style="font-size: 8pt">0.05
MB</font></td>
<td nowrap align="center" style="border-top: 1px solid
#A0C6E5">&nbsp;</td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p>&nbsp;</p>
</td>
<td vAlign="top"><uc1:ctrlrightside id="CtrlRightSide1"
runat="server"></uc1:ctrlrightside></td>
</tr>
</table>
</TD></TR>
<tr>
<td vAlign="top"><uc1:ctrlbottom id="CtrlBottom1"
runat="server"></uc1:ctrlbottom></td>
</tr>
</TBODY></TABLE></form>
</body>
</HTML>


================================================== ==========================
=====
==== Code Behind

================================================== =========


Public Class Attachments

Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub

InitializeComponent()

End Sub

Protected WithEvents btnOK As System.Web.UI.WebControls.Button

Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater

Protected WithEvents fileIn As System.Web.UI.HtmlControls.HtmlInputFile

Protected WithEvents btnAddAttachment As System.Web.UI.WebControls.Button
Protected WithEvents cvFile As System.Web.UI.WebControls.CustomValidator

Protected WithEvents ctrlPageHeaderBox As SecureEmail.ctrlPageHeaderBox

Protected WithEvents lblErrorMsg As System.Web.UI.WebControls.Label

'NOTE: The following placeholder declaration is required by the Web Form
Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

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

If Not IsPostBack Then

' if there isn't an attachments table already...

If Session("AttachmentsTable") Is Nothing Then

' get schema from db and create a table from it...

Dim dt_attachments As New DataTable

dt_attachments.Columns.Add(New DataColumn("FileName", GetType(String)))

dt_attachments.Columns.Add(New DataColumn("FileSize", GetType(Int32)))

Dim dc_ID As DataColumn = dt_attachments.Columns.Add("ID",

GetType(Integer))

dc_ID.AutoIncrement = True

dc_ID.AutoIncrementSeed = 1

dc_ID.AutoIncrementStep = 2

dc_ID.ReadOnly = True

dt_attachments.PrimaryKey = New DataColumn()

{dt_attachments.Columns("ID")}

dt_attachments.Columns.Add(New DataColumn("AttachmentData",
GetType(Byte())))

Session("AttachmentsTable") = dt_attachments

End If

If Not Request.QueryString("action") Is Nothing Then

Select Case Request.QueryString("action").ToLower

Case "remove"

Dim DR_ROW As DataRow

DR_ROW = DirectCast(Session("AttachmentsTable"),
DataTable).Rows.Find(Convert.ToInt32(Request.Query String("ID")))

DR_ROW.Delete()

End Select

End If

End If

Me.Repeater1.DataSource = Session("AttachmentsTable")

Me.Repeater1.DataBind()

End Sub

Private Sub AddAttachment()

If Me.fileIn.Value.Trim.Length = 0 Then

Me.cvFile.IsValid = False

Else

Try

Me.lblErrorMsg.Visible = False

Dim AttachedFileCollection As HttpFileCollection

Dim a As HtmlInputFile

Me.fileIn.MaxLength = (100 * 1024) ' 100 MB upload max

Dim MyFile As HttpPostedFile

Dim FileLength As Integer

Dim FileName As String

Dim FileStream As System.IO.Stream

AttachedFileCollection = Request.Files

MyFile = AttachedFileCollection(0)

FileLength = MyFile.ContentLength

Dim FileData(FileLength) As Byte

FileStream = MyFile.InputStream

FileStream.Read(FileData, 0, FileLength)

Me.cvFile.IsValid = True

Dim dr_row As DataRow = DirectCast(Session("AttachmentsTable"),
DataTable).NewRow

dr_row("FileName") = IO.Path.GetFileName(MyFile.FileName).ToUpper

dr_row("FileSize") = MyFile.ContentLength

dr_row("AttachmentData") = FileData

DirectCast(Session("AttachmentsTable"), DataTable).Rows.Add(dr_row)

Catch ex As Exception

Me.lblErrorMsg.Visible = True

Me.lblErrorMsg.Text = "Error uploading file: " & ex.Message

End Try

Me.Repeater1.DataBind()

End If

End Sub

Private Sub btnAddAttachment_Click(ByVal sender As System.Object, ByVal

e As
System.EventArgs) Handles btnAddAttachment.Click

AddAttachment()

End Sub

Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOK.Click

Response.Redirect("Compose.aspx")

End Sub

End Class


Nov 18 '05 #8
say if i wanted a 25600KB max upload (25mb) how would i instead of going to
a page not found page, instead give them a vaildation message that it cant
be this big? thanks

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Bn**************@cpmsftngxa06.phx.gbl...
Hi Brian,

I've noticed that there is another post on the <input type=file> html
control you've posted in this group, yes? Are they focus on the same issue? As the other members have mentioned, the "maxRequestLength" attribute will
limit the max length file that can be uploaded and the default is 4MB.
Also, I suggest that you have a look at the following tech article I've
mentioned in another thread:

#Uploading Files Using the File Field Control
http://msdn.microsoft.com/library/en...eupload.asp?fr ame=true#aspnet-fileupload_topic2c

If you have anything unclear or any other findings, please feel free to
post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #9
Seems you'll want to check Request.ContentLength at Application_BeginRequest
event
of Global.asax.

"Brian Henry" <br**********@newsgroups.nospam> ¦b¶l¥ó
news:O$**************@TK2MSFTNGP10.phx.gbl ¤¤¼¶¼g...
say if i wanted a 25600KB max upload (25mb) how would i instead of going to a page not found page, instead give them a vaildation message that it cant
be this big? thanks

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:Bn**************@cpmsftngxa06.phx.gbl...
Hi Brian,

I've noticed that there is another post on the <input type=file> html
control you've posted in this group, yes? Are they focus on the same

issue?
As the other members have mentioned, the "maxRequestLength" attribute will limit the max length file that can be uploaded and the default is 4MB.
Also, I suggest that you have a look at the following tech article I've
mentioned in another thread:

#Uploading Files Using the File Field Control

http://msdn.microsoft.com/library/en...eupload.asp?fr
ame=true#aspnet-fileupload_topic2c

If you have anything unclear or any other findings, please feel free to
post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx


Nov 18 '05 #10
Hi Brian,

As for the error handling of the exceeding MaxFile upload limiation in
asp.net. Currently there seems haven't any graceful way. This is because
the asp.net reject the too large request and close the connection between
those events such as BeginRequest or Application_Error which we can handle
via code. So there hasn't any better means to handle it except set the
maxRequestLength to a large size and let the file be uploaded and then
discard it. In fact, you can use the <location> element in asp.net
web.config file to set the
"maxRequestLenght" attribute to a large value only for the fileuploading
page, just like below:

<configuration>
<location path="UploadPage.aspx">
<httpRuntime maxRequestLength="128"/>
</location>
</configuration>

#<location> Element
http://msdn.microsoft.com/library/de...us/cpgenref/ht
ml/gngrflocationelement.asp

In addition, here are some former threads in the newsgroup discussing on
the same problem:

http://groups.google.com/groups?hl=e...Pk3wxMHEHA.119
2%40TK2MSFTNGP11.phx.gbl&rnum=5&prev=/groups%3Fq%3Dasp.net%2Bhandle%2Bupload
%2Bfile%2Berror%26hl%3Den%26lr%3D%26ie%3DUTF-8%26start%3D0%26sa%3DN

http://groups.google.com/groups?hl=e...OezyuCHA.2380%
40TK2MSFTNGP11&rnum=3&prev=/groups%3Fq%3Dasp.net%2Bupload%2Bmax%2Bsize%2Bche
ck%26ie%3DUTF-8%26hl%3Den

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Don | last post by:
Can't figure this one out. The "validate" function below checks to make sure the field "names" is not null. "validate" actually calls "isEmpty", which scans the field. Here's the situation. ...
5
by: Jonathan Daggar | last post by:
Hello, I'm trying to put together a form with a very tight table formatting. However, every time I put an text-type input field in, the browser pads the area to the right of it with space. I've...
2
by: not 2 swift | last post by:
I thought I would update an old page on which I had used a <INPUT TYPE=image ...> with a <BUTTON><IMG SRC=...></BUTTON> The problem is that <BUTTON> always provides a shadow/emboss effect. Can...
3
by: TR | last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox with a nested label? This is the label of the checkbox that wraps beneath it I'd prefer it looked like...
3
by: Ben | last post by:
Here's my form: <form name="aForm" method='post'> <input type=file name=file1 onkeypress='KeyPress()'><br> <a id='attachMoreLink' href='javascript:AddFileInput()">Attach More Files </a> <input...
2
by: Richard Maher | last post by:
Hi, I'm trying to use the Visibility Style attribute for a Div to effectively PopUp a lightweight window with some additional context-sensitive information, when a user mouses over a given...
5
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have a control on a page in .net 2.0: <input id="AddReport" type="file" name="AddReport" runat="server" /> which I use to get the path, etc. of a file. I then have a button: <asp:Button...
1
by: JPhilS | last post by:
Hi to all Webmaster! I have discover this problem when I inserted the scores of the students i a centain subject. I am making a school project with regards to saving students' record. first, I...
1
by: test9991014 | last post by:
Hi folks, I've got something like this: <table> <tr> <td>1</td> <td align=center> <input type=text> </td>
8
by: Zhang Weiwu | last post by:
hello. Is it possible to design CSS in the way that content in <inputare not visible in print out (a.k.a. value of <inputnot visible) while the border remain visible? trial: input {...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.