<tfoot id='mvJBD'></tfoot>
      <legend id='mvJBD'><style id='mvJBD'><dir id='mvJBD'><q id='mvJBD'></q></dir></style></legend>

      <small id='mvJBD'></small><noframes id='mvJBD'>

      1. <i id='mvJBD'><tr id='mvJBD'><dt id='mvJBD'><q id='mvJBD'><span id='mvJBD'><b id='mvJBD'><form id='mvJBD'><ins id='mvJBD'></ins><ul id='mvJBD'></ul><sub id='mvJBD'></sub></form><legend id='mvJBD'></legend><bdo id='mvJBD'><pre id='mvJBD'><center id='mvJBD'></center></pre></bdo></b><th id='mvJBD'></th></span></q></dt></tr></i><div id='mvJBD'><tfoot id='mvJBD'></tfoot><dl id='mvJBD'><fieldset id='mvJBD'></fieldset></dl></div>

        • <bdo id='mvJBD'></bdo><ul id='mvJBD'></ul>

        文件上传控制不起作用

        时间:2023-06-02
      2. <tfoot id='nUyTg'></tfoot>

            <tbody id='nUyTg'></tbody>
          • <bdo id='nUyTg'></bdo><ul id='nUyTg'></ul>

                  <small id='nUyTg'></small><noframes id='nUyTg'>

                  <i id='nUyTg'><tr id='nUyTg'><dt id='nUyTg'><q id='nUyTg'><span id='nUyTg'><b id='nUyTg'><form id='nUyTg'><ins id='nUyTg'></ins><ul id='nUyTg'></ul><sub id='nUyTg'></sub></form><legend id='nUyTg'></legend><bdo id='nUyTg'><pre id='nUyTg'><center id='nUyTg'></center></pre></bdo></b><th id='nUyTg'></th></span></q></dt></tr></i><div id='nUyTg'><tfoot id='nUyTg'></tfoot><dl id='nUyTg'><fieldset id='nUyTg'></fieldset></dl></div>
                • <legend id='nUyTg'><style id='nUyTg'><dir id='nUyTg'><q id='nUyTg'></q></dir></style></legend>
                • 本文介绍了文件上传控制不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  文件名和扩展名是空的.请帮忙.

                  ASPX 文件代码:

                  <tr><td colspan="3" style="height:0px"><div id="trFile" runat="server" class="inlineGridAddAddress"><table cellpadding="0" cellspacing="0"><tr><td><div class="formFieldName"><asp:RequiredFieldValidator ID="reqFile" runat="server"ControlToValidate="fileUpload" ErrorMessage="请选择文件"ValidationGroup="Save" CssClass="Validations" ></asp:RequiredFieldValidator></div></td></tr><tr><td><asp:Label ID="lblFile" runat="server">文件:</asp:Label></td><td>

                  <asp:FileUpload ID="fileUpload" runat="server"/></div></td><td class="tdformFieldValueLogin" style="width:350px;padding-left:50px"><asp:ImageButton ID="btnFileUploadSave" runat="server" ValidationGroup="Save"ImageUrl="~/App_Themes/Default/images/update.png" ToolTip="保存"高度="18px" onclick="btnFileUploadSave_Click"/><asp:ImageButton ID="btnFileUploadCancel" ImageUrl="~/App_Themes/Default/images/cancel.png"runat="server" ToolTip="Cancel" Height="18px"/></td></tr><tr><td><div class="formSmallTextAreaName"><asp:Label ID="lblDescription" runat="server">描述:</asp:Label></div></td><td><div class="formSmallTextAreaValue"><asp:RegularExpressionValidator ID="revNote"runat="服务器" ControlToValidate="txtDescription"ValidationExpression="^[sS]{0,4096}$"Text="最多允许 4096 个字符."CssClass="验证"显示="动态"></asp:RegularExpressionValidator><asp:TextBox ID="txtDescription"runat="server" CssClass="textEntry1"TextMode="MultiLine" MaxLength="4096" 宽度="218px"></asp:文本框></div></td></tr></表></div></td></tr>

                  CS 文件代码:

                  protected void btnFileUploadSave_Click(object sender, ImageClickEventArgs e){字符串路径 = Server.MapPath(".") + "\Files\" + this.fileUpload.FileName;字符串文件扩展 = System.IO.Path.GetExtension(this.fileUpload.FileName).ToLower();if (fileExtension == ".txt" || fileExtension == ".doc" || fileExtension == ".docx" || fileExtension == ".zip" || fileExtension == ".rar" || fileExtension ==".cs" || fileExtension == ".ppt" || fileExtension == ".pdf" || fileExtension == ".html" || fileExtension == ".jpg" || fileExtension == ".gif" || fileExtension == ".bmp" || fileExtension == ".png" || fileExtension == ".tif" || fileExtension == ".rm" || fileExtension == ".mp3" || fileExtension == ".xls"){this.fileUpload.PostedFile.SaveAs(path);}}

                  解决方案

                  如果您将 UploadControl 放在 UpdatePanel 中(Ajax 的东西),默认情况下它不会工作.使用更新面板、文件上传控件并使用 PostBackTrigger 控件强制 postback 仅用于文件上传控件

                  查看以下链接

                  文件在 UpdatePanel 中上传,ASP.NET AJAX

                  File name and extension are empty. Please help.

                  ASPX FILE CODE:

                  <tr>
                    <td colspan="3" style="height:0px">
                      <div id="trFile" runat="server" class="inlineGridAddAddress">
                        <table cellpadding="0" cellspacing="0">
                          <tr>
                            <td>
                              <div class="formFieldName">
                                <asp:RequiredFieldValidator ID="reqFile" runat="server"
                                    ControlToValidate="fileUpload" ErrorMessage="Please select File"
                                    ValidationGroup="Save" CssClass="Validations" ></asp:RequiredFieldValidator>
                              </div>
                            </td>
                          </tr>
                          <tr>
                            <td>
                              <asp:Label ID="lblFile" runat="server">File:</asp:Label>
                            </td>
                            <td>
                              <div>
                                <asp:FileUpload ID="fileUpload" runat="server" />
                              </div>
                            </td>
                            <td class="tdformFieldValueLogin" style="width:350px;padding-left:50px">
                              <asp:ImageButton ID="btnFileUploadSave" runat="server" ValidationGroup="Save"
                                  ImageUrl="~/App_Themes/Default/images/update.png" ToolTip="Save"
                                  Height="18px" onclick="btnFileUploadSave_Click"/>
                              <asp:ImageButton ID="btnFileUploadCancel" ImageUrl="~/App_Themes/Default/images/cancel.png"
                                  runat="server" ToolTip="Cancel" Height="18px" />
                            </td>
                          </tr>
                  
                          <tr>
                            <td>
                              <div class="formSmallTextAreaName">
                                <asp:Label ID="lblDescription" runat="server">Description:</asp:Label>
                              </div>
                            </td>
                            <td>
                              <div class="formSmallTextAreaValue">
                                <asp:RegularExpressionValidator ID="revNote"
                                    runat="server" ControlToValidate="txtDescription"
                                    ValidationExpression="^[sS]{0,4096}$"
                                    Text="Maximum 4096 characters are allowed."
                                    CssClass="Validations" Display="Dynamic">
                                </asp:RegularExpressionValidator>
                                <asp:TextBox ID="txtDescription"
                                    runat="server" CssClass="textEntry1"
                                    TextMode="MultiLine" MaxLength="4096" Width="218px">
                                </asp:TextBox>
                              </div>
                            </td>
                          </tr>
                        </table>
                      </div>
                    </td>
                  </tr>
                  

                  CS FILE CODE:

                  protected void btnFileUploadSave_Click(object sender, ImageClickEventArgs e)
                      {
                          string path = Server.MapPath(".") + "\Files\" + this.fileUpload.FileName;
                          string fileExtension = System.IO.Path.GetExtension(this.fileUpload.FileName).ToLower();
                          if (fileExtension == ".txt" || fileExtension == ".doc" || fileExtension == ".docx" || fileExtension == ".zip" || fileExtension == ".rar" || fileExtension == ".cs" || fileExtension == ".ppt" || fileExtension == ".pdf" || fileExtension == ".html" || fileExtension == ".jpg" || fileExtension == ".gif" || fileExtension == ".bmp" || fileExtension == ".png" || fileExtension == ".tif" || fileExtension == ".rm" || fileExtension == ".mp3" || fileExtension == ".xls")
                          {
                              this.fileUpload.PostedFile.SaveAs(path);
                          }
                      }
                  

                  解决方案

                  If you're putting your UploadControl in an UpdatePanel (Ajax stuff), it won't work by default. Use Update Panel, File Upload Control and use a PostBackTrigger Control to force a postback only for the File Upload Control

                  Check out the following link

                  File Upload in UpdatePanel, ASP.NET AJAX

                  这篇关于文件上传控制不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何为我的网络应用获取类似 Gmail 的文件上传 下一篇:上传超过 Asp.net 请求长度限制的文件?

                  相关文章

                  最新文章

                  <i id='CfQ1z'><tr id='CfQ1z'><dt id='CfQ1z'><q id='CfQ1z'><span id='CfQ1z'><b id='CfQ1z'><form id='CfQ1z'><ins id='CfQ1z'></ins><ul id='CfQ1z'></ul><sub id='CfQ1z'></sub></form><legend id='CfQ1z'></legend><bdo id='CfQ1z'><pre id='CfQ1z'><center id='CfQ1z'></center></pre></bdo></b><th id='CfQ1z'></th></span></q></dt></tr></i><div id='CfQ1z'><tfoot id='CfQ1z'></tfoot><dl id='CfQ1z'><fieldset id='CfQ1z'></fieldset></dl></div>
                • <tfoot id='CfQ1z'></tfoot>

                  <small id='CfQ1z'></small><noframes id='CfQ1z'>

                • <legend id='CfQ1z'><style id='CfQ1z'><dir id='CfQ1z'><q id='CfQ1z'></q></dir></style></legend>

                      • <bdo id='CfQ1z'></bdo><ul id='CfQ1z'></ul>