首页 新闻 会员 周边

【求助】使用ASP.NET的FileUpload控件上传文件碰到获取不到文件的情况,谁碰到过么?

0
[已解决问题] 解决于 2014-08-06 09:22

界面如上图,点浏览获取文件么,单击上传,调试代码时发现,在判断FileUpload是否有文件的时候,竟然是false,获取不到文件。。。请高手指教。。。。

问题补充:
body>
    <sunuc:Loading id="Loading1" runat="server"></sunuc:Loading>
    <form id="form1" onkeydown="return ConvertKeyCode();" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
                <cc:ToolBar ID="ExtToolbar1" runat="Server" AutoPostBack="True">
                </cc:ToolBar>
                <cc:ToolBar ID="ExtToolbar2" runat="Server" AutoPostBack="True">
                </cc:ToolBar>
                <cc:ToolBar ID="WorkflowToolbar" runat="Server" AutoPostBack="true">
                </cc:ToolBar>
                <asp:UpdatePanel ID="UpdatePanelAttachment" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <cc:ToolBar ID="AttachmentToolBar" runat="Server" AutoPostBack="true">
                </cc:ToolBar>
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="AttachmentToolBar" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanelForm" runat="server">
            <ContentTemplate>
                <cc:ExtPanel ID="ExtPanel1" runat="server">
                <table id="table1" width="100%">
                            <!--1-->
                            <tr>
                                <!--会议主题-->
                                <td style="width: 15%">
                                    <cc:ExtLabel ID="lblMeetingTopic" runat="server" Required="false"></cc:ExtLabel>
                                </td>
                                <td style="width: 35%">
                                <cc:ExtDropDownList ID="ddlMeetingTopic" Width="300" runat="server" Required="false" RequiredHintId="" ></cc:ExtDropDownList>
                               <%-- <cc:ExtTextBox ID="etxtMeetingTopic" Width="300"  runat="server" Enabled="false" ReadOnly="true"></cc:ExtTextBox>--%>
                                <asp:Image ID="imgMeetingTopic" SkinID="edit" runat="server"/>
                                </td>
                                <!--开始日期-->
                                    <td style="width: 15%">
                                        <cc:ExtLabel ID="lblStartDate" runat="server" Required="false"></cc:ExtLabel>
                                    </td>
                                    <td style="width: 35%">
                                        <cc:ExtDateField ID="ttbStartDate" runat="server" Width="160" Required="false" RequiredHintId="" ></cc:ExtDateField>
                                    </td>
                            </tr>
                            <!--2-->
                            <tr><!--文件标题-->
                                <td style="width: 15%">
                                    <cc:ExtLabel ID="lblFileTitle" runat="server" Required="false"></cc:ExtLabel>
                                </td>
                                <td style="width: 35%">
                                    <cc:ExtTextBox ID="ttbFileTitle" Width="292"  runat="server" Required="false" RequiredHintId="" ></cc:ExtTextBox>
                                </td>

                                    <!--结束日期-->
                                    <td style="width: 15%">
                                        <cc:ExtLabel ID="lblEndDate" runat="server" Required="false"></cc:ExtLabel>
                                    </td>
                                    <td style="width: 35%">
                                        <cc:ExtDateField ID="ttbEndDate" runat="server" Width="160" Required="false" RequiredHintId="" ></cc:ExtDateField>
                                    </td>
                            </tr>
                            <!--3-->
                            <tr>
                                <!--文件描述-->
                                <td style="width: 15%">
                                    <cc:ExtLabel ID="lblFileDescription" runat="server" Required="false"></cc:ExtLabel>
                                </td>
                                <td style="width: 35%">
                                <cc:ExtTextBox ID="ttbFileDescription" Width="292"  runat="server" Required="false" RequiredHintId="" ></cc:ExtTextBox>
                                </td>
                                <!--相关链接-->
                                    <td style="width: 15%">
                                        <cc:ExtLabel ID="lblFileLink" runat="server" Required="false"></cc:ExtLabel>
                                    </td>
                                    <td style="width: 35%">
                                        <cc:ExtTextBox ID="ttbFileLink" runat="server" Required="false" RequiredHintId="" ></cc:ExtTextBox>
                                    </td>
                            </tr>
                            <!--4-->
                            <tr>
                                <!--文件名称-->
                                <td style="width: 15%">
                                    <cc:ExtLabel ID="lblFileName" runat="server" Required="false"></cc:ExtLabel>
                                </td>
                                <td style="width: 35%">
                                   <%-- <cc:ExtTextBox ID="ttbFileName" runat="server" Required="false" RequiredHintId="" ></cc:ExtTextBox>--%>
                                    <asp:FileUpload runat="server" Width="300" ID="UploadFile" Height="24" BackColor="White" />
快刀客的主页 快刀客 | 初学一级 | 园豆:125
提问于:2014-08-05 22:38
< >
分享
最佳答案
0

上传文件的默认大小是4M,检查一下其他的原因。

首先看一下FileUpload(<input type="file">)是否在表单里面(form)。必须在form里面

表单的请求方式(method)是get还是post。必须是post

奖励园豆:5
写代码的小2B | 老鸟四级 |园豆:4371 | 2014-08-06 08:54

我发了代码,你帮看下。。谢谢

快刀客 | 园豆:125 (初学一级) | 2014-08-06 09:06
其他回答(2)
0

上传的文件有没有超过200kb?

I,Robot | 园豆:9783 (大侠五级) | 2014-08-06 05:42

谢谢回答,没有超过,但我想不应该是这个问题啊,hasFile获取不到文件,FileName也获取不到文件名。

支持(0) 反对(0) 快刀客 | 园豆:125 (初学一级) | 2014-08-06 08:59
0

原来是UpdatePanel不支持上传。。

快刀客 | 园豆:125 (初学一级) | 2014-08-06 09:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册