如何在asp.net中上传文件 [英] how to upload file in asp.net

查看:55
本文介绍了如何在asp.net中上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生;

我正在使用此代码在asp.net中上传文件

当我使用saperate页面(不带母版页面)时,它工作得很好.
但是当它与母版页一起使用并进行调试然后上载时.HasFile错误跳转到
尝试阻止零件.



如何解决..

dear sir;

i am using this code for upload file in asp.net

it is work nicely when i use saperate page(without master page )
but when it use with master page and debuge it then upload.HasFile false jump to
try block part.



how to solve it..

Protected Sub btnupload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnupload.Click
       If upload.HasFile Then
           Try
               'Dim fileName As String = Path.GetFileName(Me.fileResume.FileName)
               Dim filename As String = Path.GetFileName(Me.upload.FileName)
               'Session("sessionfilename") = filename
               upload.SaveAs(Server.MapPath("~/IMEINO/") & filename)
           Catch ex As Exception

           Finally
               lblMsg.Text = "<font color='green'>Data Insert Sucessfully</font>"
               lblMsg.ForeColor = System.Drawing.Color.Red

           End Try
       End If
   End Sub




这是,, ..




here is ,,..

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"

    CodeFile="AddIMEI.aspx.vb" Inherits="AddIMEI" Title="Ultimate RMA : IMEI NO." %>

<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="Server">
    <div style="width: 960px;" align="left">
        <asp:UpdatePanel ID="updpnlOrderParts" runat="server">
            <ContentTemplate>

<pre lang="xml"><div>
                    <table width="100%">
                        <tr>
                            <td align="right" style="width: 50%;">
                                <asp:FileUpload ID="upload" runat="server" />
                            </td>
                            <td align="left">
                                <asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="btnUpload_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                            </td>
                            <asp:Label ID="lblMsg" runat="server"></asp:Label>
                        </tr>
                    </table>
                </div>
                <div>
                    <table width="100%">
                        <tr>
                            <td  align="center" >
                            <asp:Button ID="btnInsert" runat="server" Text="Add IMEINO" />


                            </td>
                        </tr>
                    </table>
                </div>


</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>


</div>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>

推荐答案

此链接可能对您有帮助
使用ASP.NET上传文件 [
this link might help you
File Upload with ASP.NET[^]


刚刚回答了类似的问题 ^ ].
Just answered a similar question here[^].


这篇关于如何在asp.net中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆