필요한  오픈 컴포넌트

ajaxfileupload.js

http://www.phpletter.com/Our-Projects/AjaxFileUpload/

 

 

  스크립트 부분

 function ajaxFileUpload(index)
{
 var filePath = document.fileUploadForm.elements["file_img_"+index].value;
 if ( !(filePath.match(/\.(gif|jpg|jpeg|png)$/i)) ){ 
  modal.alert("이미지 파일을 선택해주세요.");
  return true;
 }
 
 $.ajaxFileUpload
 (
  {
   url:'주소',
   secureuri:false,
   fileElementId:'file_img_'+index,
   dataType: 'json',    
   success: function (data, status)
   {
       //처리프레서스

      //data  json 객체 이미 처리되어 넘어옴
     },
   error: function (data, status, e)
   {
    alert(e);
   }
  }
 )
 return false;
}

 

# 작동 방식

페이지에 파일 input 박스를 찾는다 [이름지정]

그후 아이프레임 만든후 넘어온 데이터를 success에다가 데이터를 넣어준다.

 

ps : iframe가 안돼는 부라우저에서는 실행 불가능할것으로 예상된다.

 

 

참고 자료

http://whitememo.tistory.com/167

http://malsup.com/jquery/form/progress3.html