< INPUT ='文件'>上传问题 [英] <INPUT = 'File'> upload problem
问题描述
我在使用附件系统时遇到问题...它适用于大小约3MB的
文件然后如果您尝试上传文件只是
转到无法显示页面这样的页面试图这样做但是
错误...我想把文件输入框的最大尺寸更改为大约
100mb会修复它但是没有
这是我的页面代码和代码背后的代码...
== [html page] ========== ===
<%@ Page Language =" vb" AutoEventWireup =" false"
Codebehind =" Attachments.aspx.vb" Inherits =" SecureEmail.Attachments"%>
<%@ Register TagPrefix =" cc1"命名空间= QUOT; SecureEmail" Assembly =" SecureEmail"
%>
<%@ Register TagPrefix =" uc1"标签名= QUOT; 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安全电子邮件网络< / title>
< meta content =" SharePoint.WebPartPage。文件" 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 = QUOT; 0" TOPMARGIN = QUOT; 0" rightMargin =" 0"
MS_POSITIONING =" GridLayout">
< form id =" Form1"方法= QUOT;交" runat =" server">
< table id =" table1"高度= QUOT; 100%QUOT; CELLSPACING = QUOT; 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"高度= QUOT; 100%QUOT; CELLSPACING = QUOT; 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 = QUOT; 0" CELLPADDING = QUOT; 0" width =" 100%"
bgColor ="#a0c6e5" border =" 0"
class =" toolbar">
< TR>
< TD>
< p align =" left">< asp:button id =" btnOK" RUNAT = QUOT;服务器" Text =" OK"
字体大小=" 8pt">< / asp:按钮>& nbsp;< asp:button id =" btnAddAttachment"
runat =" server" Text =" Add Attachment"字体大小=" 8pt">< / asp:button>< / p>
< / TD>
<>& nbsp ;< / TD>
< / TR>
< / TABLE>
< table border =" 0"宽度= QUOT; 100%QUOT; ID = QUOT;表6" cellspacing =" 0"
cellpadding =" 0">
< tr>
< td>
< cc1:ctrlPageHeaderBox id =" ctrlPageHeaderBox" runat =" server"
字体大小=" 8pt" AutoPostBack =" True"
Text =" Attachments">< / cc1:ctrlPageHeaderBox>< / td>
< / tr>
< / table>
< table id =" table3" CELLPADDING = QUOT; 0"宽度= QUOT; 100%QUOT; border =" 0">
< TBODY>
< tr>
< td>< FONT face =" ; Arial字体" size =" 1">眉毛附件使用
浏览按钮,然后
点击添加附件将其添加到附件
list。< / FONT>< / td>
< / tr>
< tr>
< td> & nbsp;< INPUT id =" fileIn"类型= QUOT;文件" name =" fileIn"
runat =" server">
< asp:Label id =" lblErrorMsg" RUNAT = QUOT;服务器"字体大小=" 8pt"
字体名称=" verdana" ForeColor =" Red">< / asp:Label>
< asp:customvalidator id =" cvFile" RUNAT = QUOT;服务器"字体大小=" 8pt"
ErrorMessage ="必须指定文件
字体名称=" Verdana">< / asp:customvalidator> < / td>
< / tr>
< tr>
< td>& nbsp;< FONT face = QUOT; Arial字体" size =" 1">当前附件
消息:< / FONT>< / td>
< / tr>
< tr>
< td>< asp:repeater id =" Repeater1" runat =" server">
< HeaderTemplate>
< table border =" 0"宽度= QUOT; 350" ID = QUOT;表5" 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">删除< / span>< ; / font>< / td>
< / tr>
< / HeaderTemplate>
< ItemTemplate>
< tr>
< td width =" 100%" align =" left">
< font size =" 2" face =" Arial">< img border =" 0"
src =" ../ images / attachfile.gif"宽度= QUOT; 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 =" ../图像/ delete.gif" width =" 16"
height =" 16">< / a>< / td>
< / tr>
< / ItemTemplate>
< FooterTemplate>
< tr>
< td width =" 100%" ;对齐= QUOT;左" style =" border-top:1px solid
#A0C6E5">
< p align =" right">
< font face =" Arial" style =" font-size:8pt">总计< / 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>
============================ ====================== ========================== />
=====
====代码背后========================= ========================= =========
公共类附件
继承System.Web.U I.Page
#Region" Web窗体设计器生成的代码
''Web窗体设计器需要此调用。
< System.Diagnostics.DebuggerStepThrough ()> Private Sub InitializeComponent()
End Sub
受保护的事件btnOK As System.Web.UI.WebControls.Button
受保护的WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
受保护的WithEvents fileIn As System.Web.UI.HtmlControls.HtmlInputFile
受保护的事件btnAddAttachment As System.Web.UI.WebControls.Button
受保护的事件cvFile As System.Web.UI.WebControls.CustomValidator
受保护的WithEvents ctrlPageHeaderBox As SecureEmail.ctrlPageHeaderBox
受保护的事件lblErrorMsg As System.Web.UI.WebControls.Label
''注意:Web表格需要以下占位符声明
设计师。
''不要删除或移动它。
私有designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理MyBase.Init
''CODEGEN:Web表单设计者需要此方法调用
''不要使用代码编辑器修改它。
InitializeComponent()
End Sub
>
#End Region
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理MyBase.Load
''用户代码初始化页面
如果不是IsPostBack那么
''如果还没有附件表......
如果会话(附件表)没什么那么
''从db获取模式并从中创建一个表...
Dim dt_attachments As New DataTable
dt_attachments.Columns.Add(新DataColumn(" FileName",GetType(String)))
dt_attachments.Columns.Add(New DataColumn(" FileSize",GetT) ype(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 =新DataColumn(){dt_attachments.Columns(" ID")}
dt_attachments.Columns.Add(New DataColumn(" AttachmentData",
GetType(Byte())))
Session(" AttachmentsTable")= dt_attachments
结束如果
如果不是Request.QueryString(" action")什么都没有呢
选择案例Request.QueryString(" action")。ToLower
案例删除
Dim DR_ROW As DataRow
DR_ROW = DirectCast(会话(" AttachmentsTable)),
DataTable).Rows.Find(Convert.ToInt32(Request.Query Strin) g(ID)))
DR_ROW.Delete()
结束选择
结束如果
结束如果
Me.Repeater1.DataSource = Session(" AttachmentsTable")
>
Me.Repeater1.DataBind()
End Sub
Private Sub AddAttachment()
>
如果Me.fileIn.Value.Trim.Length = 0那么
Me.cvFile.IsValid = False
Else
尝试
Me.lblErrorMsg.Visible = False
Dim AttachedFileCollection As HttpFileCollection
Dim a As HtmlInputFile
Me.fileIn.MaxLength =(100 * 1024)''最大上传100 MB
>
Dim MyFile作为HttpPostedFile
Dim FileLength作为整数
Dim FileName As String
Dim FileStream As System.IO.Stream
AttachedFileCollection = Request.Files
MyFile = AttachedFileCollecti on(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(会话(" AttachmentsTable"),DataTable).Rows.Add(dr_row)
Catch ex As Exception
Me.lblErrorMsg.Visible = True
Me.lblErrorMsg.Text ="错误上传文件: &安培; ex.Message
结束尝试
Me.Repeater1.DataBind()
结束如果
End Sub
Private Sub btnAddAttachment_Click(ByVal sender As System.Object,ByVal e As
系统。 EventArgs)处理btnAddAttachment.Click
AddAttachment()
End Sub
Private Sub btnOK_Click (ByVal sender As System.Object,ByVal e As
System.EventArgs)处理btnOK.Click
Response.Redirect(" Compose.aspx")
结束子
结束班
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> <asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD> </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> <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> <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"> </td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p> </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
推荐答案
有在上传之前检查页面是否超时
完成了吗?
-
---- -------------------------------------------------- ----------
- ** -
www.byteboss.com :EZ网站建设者
- ** -
Repl将Z与e一起回复
---------------------------------- ------------------------------
" Brian Henry" <峰; br ********** @ newsgroups.nospam>在消息中写道
新闻:eW ************* @ TK2MSFTNGP12.phx.gbl ...
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...
我有一个我制作的附件系统的问题...它的工作量为b $ b,文件大小约为3MB,之后如果你试图上传文件,那么
只会转到页面无法显示 ;这样的页面试图这样做但是
错误...我想将文件输入框的最大尺寸更改为
约100mb会修复它但是没有
这里是我的页面代码和代码背后的代码...
== [html page] =============
<%@ Page语言= QUOT; VB" AutoEventWireup =" false"
Codebehind =" Attachments.aspx.vb" Inherits =" SecureEmail.Attachments"%>
<%@ Register TagPrefix =" cc1"命名空间= QUOT; SecureEmail"
Assembly =" SecureEmail" %>
<%@ Register TagPrefix =" uc1"标签名= QUOT; 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安全电子邮件网络< / 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 = QUOT; 0" TOPMARGIN = QUOT; 0" rightMargin =" 0"
MS_POSITIONING =" GridLayout">
< form id =" Form1"方法= QUOT;交" runat =" server">
< table id =" table1"高度= QUOT; 100%QUOT; CELLSPACING = QUOT; 0" cellPadding =" 0"
width =" 100%" border =" 0">
< tr>
< td vAlign =" top">< uc1:ctrltop id =" CtrlTop1"
runat ="服务器">< / uc1:ctrltop>< / td>
< / tr>
< tr>
< td vAlign =" top" height =" 100%">
< table id =" table2"高度= QUOT; 100%QUOT; CELLSPACING = QUOT; 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 = QUOT; 0" CELLPADDING = QUOT; 0" width =" 100%"
bgColor ="#a0c6e5" border =" 0"
class =" toolbar">
< TR>
< TD>
< p align =" left">< ; asp:button id =" btnOK" RUNAT = QUOT;服务器"
Text =" OK"字体大小=" 8pt">< / asp:button>& nbsp;< asp:button id =" btnAddAttachment"
runat =" server" Text =" Add Attachment"字体大小=" 8pt">< / asp:button>< / p>
< / TD>
< TD>& nbsp;< / TD>
< / TR>
< / TABLE>
< table border =" 0"宽度= QUOT; 100%QUOT; ID = QUOT;表6" 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 = QUOT; 0"宽度= QUOT; 100%QUOT; border =" 0">
< TBODY>
< tr>
< td>< FONT face =" Arial" size =" 1">使用浏览按钮浏览附件,然后单击添加附件将其添加到附件
列表。< / FONT>< / td> ;
< / tr>
< tr>
< td>& nbsp;< INPUT id =" fileIn"类型= QUOT;文件" name =" fileIn"
runat =" server">
< asp:Label id =" lblErrorMsg" RUNAT = QUOT;服务器" Font-Size =" 8pt"
Font-Names =" verdana" ForeColor =" Red">< / asp:Label>
< asp:customvalidator id =" cvFile" RUNAT = QUOT;服务器"
字体大小=" 8pt" ErrorMessage =必须指定文件
字体名称=" Verdana">< / asp:customvalidator>< / td>
< / tr>
< tr>
< td>& nbsp;< FONT face =" Arial" size =" 1">
消息的当前附件:< / FONT>< / td>
< / tr>
< tr>
< td>< asp:repeater id =" Repeater1" runat =" server">
< HeaderTemplate>
< table border =" 0"宽度= QUOT; 350" ID = QUOT;表5" cellspacing =" 0"
cellpadding =" 5" style =" border:1px solid#A0C6E5">
< tr>
< td bgcolor ="#A0C6E5" width =" 100%">
< font face =" Arial" style =" font-size:
8pt">附件< / font>< / td>
< td bgcolor ="#A0C6E5" nowrap>
< font face =" Arial">< span style =" font-size:
8pt">尺寸< / span>< / font>< / td> ;
< td bgcolor ="#A0C6E5" nowrap>
< font face =" Arial">< span style =" font-size:
8pt">删除< / span>< / font>< / td> ;
< / tr>
< / HeaderTemplate>
< ItemTemplate>
< tr>
< td width =" 100%" align =" left">
< font size =" 2" face =" Arial">< img border =" 0"
src =" ../ images / attachfile.gif"宽度= QUOT; 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 =''附件。 aspx?action = remove& id =<%#
DataBinder.Eval(Container.dataitem," ID")%>''>
< img border =" 0" SRC =" ../图像/ delete.gif" width =" 16"
height =" 16">< / a>< / td>
< / tr>
< / ItemTemplate>
< FooterTemplate>
< tr>
< td width =" 100%"对齐= QUOT;左" 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>
========================================== ======== ========================== =====
==== $背后的代码b $ b =============================================== === =========
公共类附件
继承System.Web.UI.Page
#Region" ; Web窗体设计器生成的代码
Web窗体设计器需要此调用。
< System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
受保护的事件btnOK As System.Web.UI.WebControls.Button
受保护的WithEvents Repeater1作为系统。 Web.UI.WebControls.Repeater
受保护的WithEvents fileIn As System.Web.UI.HtmlControls.HtmlInputFile
受保护的事件btnAddAttachment As System.Web.UI.WebControls.Button <受保护的事件cvFile As System.Web.UI.WebControls.CustomValidator
受保护的事件ctrlPageHeaderBox As SecureEmail.ctrlPageHeaderBox
受保护的事件lblErrorMsg As System.Web .UI.WebControls.Label
''注意:Web表格
设计师需要以下占位符声明。
''不要删除或移动它。
私有designerPlaceholderDeclaration As System.Object
私有子Page_Init(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理MyBase.Init < CODGEN:这是我Web表单设计器需要调用
''不要使用代码编辑器修改它。
InitializeComponent()
结束Sub
#End Region
私有Sub Page_Load(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理MyBase.Load
''用户代码初始化页面
如果不是IsPostBack那么
''如果没有附件表... >
如果Session(AttachmentsTable)什么都没有那么
''从db获取模式并从中创建一个表...
Dim dt_attachments As新的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.Auto IncrementSeed = 1
dc_ID.AutoIncrementStep = 2
dc_ID.ReadOnly = True
dt_attachments.PrimaryKey =新DataColumn()
{ dt_attachments.Columns(" ID")}
dt_attachments.Columns.Add(New DataColumn(" AttachmentData",
GetType(Byte())))
会话( " AttachmentsTable")= dt_attachments
结束如果
如果不是Request.QueryString(" action")什么都没有呢
选择案例请求.QueryString(" action")。ToLower
案例删除
Dim DR_ROW As DataRow
DR_ROW = DirectCast(会话(&) ; AttachmentsTable"),
DataTable).Rows.Find(Convert.ToInt32(Request.Query String(" ID"))))
DR_ROW.Delete()
<结束选择
结束如果
结束如果
Me.Repeater1.DataSource = Session(" AttachmentsTable")
Me.Repeater1.DataBind()
结束子
私人Sub AddAttachment()
如果Me.fileIn.Value.Trim.Length = 0那么
Me.cvFile.IsValid = False
其他
尝试
Me.lblErrorMsg.Visible = False
Dim AttachedFileCollection作为HttpFileCollection
Dim a As HtmlInputFile >
Me.fileIn.MaxLength =(100 * 1024)''最大100 MB上传
Dim MyFile作为HttpPostedFile
Dim FileLength作为整数
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 =真
Dim dr_row As DataRow = DirectCast(Session( " AttachmentsTable"),
DataTable).NewRow
dr_row(" FileName&quo t;)= IO.Path.GetFileName(MyFile.FileName).ToUpper
dr_row(" FileSize")= MyFile.ContentLength
dr_row(" AttachmentData") = FileData
DirectCast(会话(" AttachmentsTable)),DataTable).Rows.Add(dr_row)
Catch ex As Exception
我.lblErrorMsg.Visible = True
结束尝试
Me.Repeater1.DataBind()
结束如果
End Sub
As System.EventArgs)处理btnAddAttachment.Click
AddAttachment()
> End Sub
Private Sub btnOK_Click(ByVal sender As System.Object,ByVal e As
System.EventArgs)处理btnOK.Click
Response.Redirect(" ; Compose.aspx")
End Sub
结束类
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> <asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD> </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> <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> <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"> </td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p> </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
this瞬间发生......当我点击附加按钮时,它就会直接到页面无法显示页面......我在哪里可以看到
时间虽然设置了吗?
" Mark" <毫安** @ Z-Zvolution.nZt> wrote in message
news:cd**********@lust.ihug.co.nz...
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...
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
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
files up to ~3MB in size then after that if you try to upload a file it
just
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
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
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"
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"
Assembly="SecureEmail"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlTop"
%>
<%@ Register TagPrefix="uc1" TagName="ctrlTop"
Src="../Themes/ctrlTop.ascx"
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"方法= QUOT;交" runat="server">
<table id="table1"高度= QUOT; 100%QUOT; 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"高度= QUOT; 100%QUOT; 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 = QUOT; 0" width="100%"
bgColor="#a0c6e5" border="0"
class="toolbar">
<TR>
<TD>
<p align="left"><asp:button id="btnOK" runat="server"
%>
<%@ 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"
Text="OK"
Font-Size="8pt"></asp:button> <asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD> </TD>
</TR>
</TABLE>
<table border="0"宽度= QUOT; 100%QUOT; 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 = QUOT; 0"宽度= QUOT; 100%QUOT; 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> <INPUT id="fileIn"类型= QUOT;文件" name="fileIn"
runat="server">
<asp:Label id="lblErrorMsg" RUNAT = QUOT;服务器" Font-Size="8pt"
Font-Names="verdana" ForeColor="Red"></asp:Label>
<asp:customvalidator id="cvFile" runat="server"
Font-Size="8pt"></asp:button> <asp:button id="btnAddAttachment"
runat="server" Text="Add Attachment" Font-Size="8pt"></asp:button></p>
</TD>
<TD> </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> <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"
Font-Size="8pt"
ErrorMessage="Must specify a file"
Font-Names="Verdana"></asp:customvalidator></td>
</tr>
<tr>
<td> <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">
<%#
ErrorMessage="Must specify a file"
Font-Names="Verdana"></asp:customvalidator></td>
</tr>
<tr>
<td> <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
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%"对齐= QUOT;左" 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"> </td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p> </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>
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"> </td>
</tr>
</table>
</FooterTemplate> </asp:repeater></td>
</tr>
</table>
<p> </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
=====
==== 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
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()
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 M yBase.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",
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(Intege r))
GetType(Integer))
dc_ID.AutoIncrement = True
dc_ID.AutoIncrementSeed = 1
dc_ID.AutoIncrementStep = 2
dc_ID.ReadOnly = True
dt_attachments.PrimaryKey = New DataColumn()
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("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.Repeat er1.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
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
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
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
On Tue, 20 Jul 2004 15:14:16 -0400, "Brian Henry"
<br**********@newsgroups.nospam> wrote:
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...
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
这篇关于< INPUT ='文件'>上传问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!