지금 시각은 입니다.
닷넷 문제없어!
[Log-In]
관리자 로그인
  ID
  PW
Catagory
탐색 건너뛰기 링크입니다.
4월2024년 5월6월
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Tag Storm
감자탕  기네스  라푼젤  사용자정의 컨트롤  위도 경도 거리  위도경도거리  정규식  파일업로드  페이징  clear  display  float  InvalidOperationException  ip차단  onClientClick  RegisterClientScriptBlock  RegisterStartupScript  urlscan  WebKnight  z-index  
RSS 2.0   
Today : 74
Total  : 524735
닷넷 2.0 - 간단한 다중파일 업로드 | ASP.Net Read : 5889
 Name : 이종원 IP : 121.55.110.129 
 Date : 2010-06-27 오후 11:46:56  
파일형태, 확장자등 가져옵니다.
2개든 3개든 업로드되지만 딱봐도 부족한게 보이죠 그거는 추가하시고요.

-- aspx
<form id="form1" method="post" runat="server" enctype="multipart/form-data">

      <div align="center">

        <h3>Test</h3>

        <INPUT type="file" size="50" NAME="File"><br />

        <INPUT type="file" size="50" NAME="File">

        <P>

                  <asp:Button Runat="server" Text="업로드" ID="UploadButton"

OnClick="UploadButton_Click"></asp:Button>

        </P>

        <P>

        <asp:Label id="strStatus" runat="server" Font-Names="" Font-Bold="True" Font-Size="9pt"

          Width="500px" BorderStyle="None" BorderColor="White"></asp:Label>

        </P>

      </div>

    </form>


--cs

protected void UploadButton_Click(object sender, EventArgs e)

    {
        HttpFileCollection files = HttpContext.Current.Request.Files;



        System.Text.StringBuilder strMsg = new System.Text.StringBuilder();

        strMsg.Append("상태정보:<hr color=red>");

        try

        {
            for (int iFile = 0; iFile < files.Count; iFile++)

            {

                   HttpPostedFile postedFile = files[iFile];

                string fileName, fileExtension;

                fileName = System.IO.Path.GetFileName(postedFile.FileName);

                if (fileName != "")

                {

                    fileExtension = System.IO.Path.GetExtension(fileName);

                    strMsg.Append("파일형식:" + postedFile.ContentType.ToString() + "<br>");

                    strMsg.Append("파일이름:" + postedFile.FileName + "<br>");

                    strMsg.Append("파일이름:" + fileName + "<br>");

                    strMsg.Append("파일확장자:" + fileExtension + "<br><hr>");

                     postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("Upload/") + fileName);

                }
            }

            strStatus.Text = strMsg.ToString();

            //r//eturn;
        }

        catch (System.Exception Ex)

        {

            strStatus.Text = Ex.Message;

            //return false;
        }
    }

출처 : http://www.taeyo.net/Forum/Content.aspx?SEQ=1236&TBL=KNOWHOW 태요 사이트의 popori0011 님글 중에서
 Tag : 파일업로드
 Trackback : http://wonpaper.net/Trackbackhandler.ashx/board_aspnet/3
이름
비번
글목록
Copyright 2010 ~ 2024, wonpaper.net based on ASP.NET 3.5 using Web-Form.
Wonpaper 웹개발자의 닷넷블로그