CAFE

ASP.NET 질문

Re:설명서 부분중에서 참고하세요.

작성자비의 Rhapsody|작성시간07.02.06|조회수121 목록 댓글 0

 

 아래부분을 응용하여 디자이너와 코더와 협업하여 디자인을 겸비한

 

 파일 업로드 상태 프로그래스바를 만드실 수 있습니다.^^

 

 

DEXTUpload.NET Professional 메뉴얼에서요.

 

DEXTUpload.NET Professional 프로그래밍 => 업로드 상태정보

 

 

=> 사용자 정의형 업로드 진행 정보창 부분입니다.

 

 

 사용자 정의형 업로드 진행 창

DEXTUpload.NET Professional
이 제공하는 업로드 진행 정보 객체를 사용하면 ActiveX Control이나 Java Applet‎과 같은 별도의 클라이언트 소프트웨어를 사용하지 않아도 파일 업로드 진행 상태를 시각적으로 보여주고, 업로드 속도, 전체 컨텐츠의 크기 및 현재 업로드 된 컨텐츠의 크기, 남은 시간, 현재 진행되고 있는 작업 등의 정보를 실시간으로 모니터링할 수 있습니다.
업로드 진행 창을 변경하려면, 샘플 프로그램에서 ShowProgress.aspx 파일을 편집하면 됩니다.

이 기능은 Progress 객체를 통해서 구현되며 다음과 같은 프로퍼티가 제공됩니다.

TotalSize : 전체 업로드 하는 크기
TransferSize :
전송 데이타 크기(Byte)
Percent :
업로드 진행률
BytesPerSec :
업로드 속도 초당 Byte
TimeLeft: 남은 시간
TimeElapsed : 현재까지 걸린 시간
isUploadClosed:
업로드가 완료(true) 또는 IE 중지 버튼 누를 시(false)

입력 폼 페이지

<%@Page...%>
......
<HEAD>
<script language="xxjavascript">
<!--
function ShowProgress()
{
   strAppVersion = navigator.appVersion;

   if(document.write_form.file1.value != "")
   {
      ProgressID = (new Date()).getTime() % 1000000;
      if (ProgressID==0) ProgressID = 1000000;

      winstyle = "dialogWidth=385px; dialogHeight:160px; center:yes";
      window.showModelessDialog("ShowProgress.aspx?ProgressID="+ProgressID, null, winstyle);

      document.write_form.action = "NewProgress_Process.aspx?ProgressID=" + ProgressID;
   }

   return true;
}
//-->
</script>
</HEAD>
<form name="write_form" enctype="multipart/form-data" method="post" action="NewProgress_Process.aspx?ProgressID=0" [안내]태그제한으로등록되지않습니다-xxonsubmit="return ShowProgress();">
<input type="file" name="file1"><br>
<input type="submit" name="Upload" value="Upload">
</form>


업로드 처리 페이지

private void Page_Load(object sender, System.EventArgs e)

{
  
using (DEXTUpload.NET.FileUpload fileUpload = new DEXTUpload.NET.FileUpload())

   {

           fileUpload.Save();
            //동일한 구문

           // fileUpload["file1"].Save();    

           // fileUpload["file1"][0].Save(); 

   }

}


업로드 진행표시 페이지#1(ShowProgress.aspx)

<%@Page...%>
<%
Response.Write("<meta HTTP-EQUIV='Refresh' CONTENT='1'>");

if(isUploadClosed)
{
   //업로드가 완료 또는 IE 중지 버튼 누를 시
   Response.Write("<body [안내]태그제한으로등록되지않습니다-xxonload='xxjavascript: top.window.close();'>");
}
else
{
   Response.Write("<table border=0 style='position:absolute;top:0px;left:0px; FONT-SIZE: 9pt' width=370 cellpadding=0 cellspacing=0 bgcolor=#d4d0c8>");
   Response.Write("<tr>");
   Response.Write(" <td colspan=2 height=5 valign=bottom><b>파일 업로드 중... </b></td>");
   Response.Write( "</tr>");
   Response.Write("<tr>");
   Response.Write( " <td colspan=2 width=370>");
   Response.Write( " <table style='left:10px; border:solid 1px;' width=370 height=15 cellpadding=0 cellspacing=0 bordercolor=#000000 leftmargin=0 topmargin=0>");
   Response.Write( " <tr>");
   Response.Write( " <td width=100% height=100% align=left valign=middle style=padding:1;>");
   Response.Write( " <table height=100% cellpadding=0 cellspacing=0 width =" + (3.7*Percent) + "></td>");
   Response.Write( " <tr><td bgcolor='darkblue'></td></tr>");
   Response.Write( " </table>");
   Response.Write( " </td>");
   Response.Write( " </tr>");
   Response.Write( " </table>");
   Response.Write( " </td>");
   Response.Write( "</tr>");
   Response.Write( "<tr><td>&nbsp;</td></tr>");
   Response.Write( "<tr>");
   Response.Write( " <td align=left>전송 속도 : " + BytesPerSec + " MB / sec </td>");
   Response.Write("&nbsp;");
   Response.Write( " <td align=middle>진행률 : " + TransferSize + " MB / " + TotalSize + " MB (" + Percent + "%)</td>");
   Response.Write( "</tr>");
   Response.Write( "<tr><td colspan=2 height=10>Click the <b>STOP</b> button on your browser to abort uploading.</td></tr>");
   Response.Write( "</table>");
   Response.Flush();
}
%>


<meta HTTP-EQUIV='Refresh' CONTENT='1'> 를 이용하여 1초 마다 Refresh하여 업로드 상태 정보를 가져 옵니다.
 


업로드 진행표시 페이지#2
(ShowProgress.aspx.cs)

public class ShowProgress : System.Web.UI.Page
{
    public int TransferSize; //업로드된 크기
    public int Percent;      //업로드 퍼센트
    public int TimeElapsed; //현재까지 걸린 시간
    public int TimeLeft;     //남은시간
    public int TotalSize;    //전체크기
    public int BytesPerSec; //초당 바이트 수(전송속도)
    public bool isUploadClosed; //업로드가 완료(true) 또는 IE 중지 버튼 누를 시(false)

    private void Page_Load(object sender, System.EventArgs e)
    {
       using (DEXTUpload.NET.Progress progress = new DEXTUpload.NET.Progress())
       {
          TransferSize = (int)Math.Round((double)progress.TransferSize / (1024*1024));
          Percent = progress.Percent;
          TimeElapsed = progress.TimeElapsed;
          TimeLeft = progress.TimeLeft;
          TotalSize = (int)Math.Round((double)progress.TotalSize / (1024*1024));
          BytesPerSec = (int)Math.Round((double)progress.BytesPerSec / (1024*1024));
          isUploadClosed = progress.IsUploadClosed;
       }
    }
}

 

출처: Devpia 메뉴얼 ^^;

 

 

 

다음검색
현재 게시글 추가 기능 열기

댓글

댓글 리스트
맨위로

카페 검색

카페 검색어 입력폼