<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>비동기 파일업로드 (www.hanji.pe.kr)</title>
<link href="/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript">
<!--
//ajax오류시 메세지 나오게함
$(document).ajaxError(function(info,xhr){
if(xhr.status==500)
alert("데이터 저장시 오류가 발생하였습니다.");
});
//파일전송 후 콜백 함수
function FileuploadCallback(data,state){
if (data=="error"){
alert("파일전송중 오류가 발생하였습니다.\n다시한번 시도해주세요.");
//location.reload();
return false;
}
alert("파일전송이 완료되었습니다.");
}
//비동기 파일 전송
$(function(){
var frm=$('#frmFile');
frm.ajaxForm(FileuploadCallback);
frm.submit(function(){return false; });
});
// 파일업로드 이벤트
function FileUpload(){
if(!$("#Filename").val()){
alert("파일을 선택하세요.");
$("#Filename").focus();
return;
}
//파일전송
var frm;
frm = $('#frmFile');
frm.attr("action","./ajax_fileupload.asp");
frm.submit();
}
-->
</script>
</head>
<body>
<div style="width:350px">
<form id="frmFile" name="frmFile" method="post" enctype="multipart/form-data">
<table cellpadding="0" cellspacing="1" id="TableSt01" class="row" style="width:350px">
<tr><th><h2>파일을 선택하세요.</h2></th></tr>
<tr><td>
<input type="file" size="30" name="Filename" id="Filename" />
<input type="button" class="btn menu" value="확인" onclick="FileUpload();" />
</td></tr>
</table>
</form>
</body>
</html>