2011-09-07 4 views

답변

0

페이지에서 FileUpload 컨트롤을 쉽게 만들 수 있습니다. 그래서 사용자가 "더 많은 업로드"링크를 선택하면 다른 FileUpload 컨트롤이 생성됩니다.

0
1.First put the Fileupload control in webform. 

`<asp:FileUpload runat="server" ID="UploadImages" AllowMultiple="true" />` 

    2.Put the Button and Label like this. 

`<div> 
    <asp:FileUpload runat="server" ID="UploadImages" AllowMultiple="true" /> 
    <asp:Button runat="server" ID="uploadedFile" Text="Upload" OnClick="uploadFile_Click" /> 
    <asp:Label ID="listofuploadedfiles" runat="server" /> 
</div>` 

3.Write the code in button click. 

`protected void uploadFile_Click(object sender, EventArgs e) 
{ 
    if (UploadImages.HasFiles) 
    { 
     foreach (HttpPostedFile uploadedFile in UploadImages.PostedFiles) 
     { 
      uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"), 
      uploadedFile.FileName)); listofuploadedfiles.Text += String.Format("{0}<br />", uploadedFile.FileName); 
     } 
    } 
}` 
관련 문제