|
닷넷 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
|
|
|
|
|
|
|
|
|
|