weixin_33701564 2015-12-30 05:37 采纳率: 0%
浏览 48

如何在ASP.NET中上传文件

Hi I created button 'UploadDocument' and with popup window after I upload documents using browse in popup window and click ok its should display documents names in 'aspx page' but not displaying please suggest me how to do this...Below is the code

 <div id="popup1" class="overlay">
 <div class="popup">
<h2>Upload Document</h2>
<a class="close" href="#">×</a>
<div class="content">
<form action="" method="post" enctype="multipart/form-data" name="form" id="form1">
<label>Choose File
<asp:Fileupload ID="FileUpload1" class="multi" runat="server"></asp:Fileupload>
  <label> Destination Folder
     <asp:Fileupload ID="FileUpload2" class="multi" runat="server"></asp:Fileupload>
       <br />
       </label>
   </form>
<asp:Button ID="btnOk" runat="server" Text="OK" />
 <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
  </div>
 </div>
 </div>


    Private Sub button1_Click(sender As Object, e As EventArgs) HandlesButton1.Click
           If FileUpload1.HasFile Then
       Try
             UploadDocument(FileUpload1.PostedFile.FileName, FileUpload1.FileName)
       Catch ex As Exception
        Label1.Text = "ERROR: " & ex.Message.ToString()
       End Try
   Else
   Label1.Text = "You have not specified a file."
    End If
End Sub
  • 写回答

2条回答 默认 最新

  • ??yy 2015-12-30 06:07
    关注

    if u don't have code behind file then how's it work! U have to code on button of file upload.

     protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.FileUpload1.HasFile)
        {
            this.FileUpload1.SaveAs("c:\\" + this.FileUpload1.FileName);
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。