2013년 10월 19일 토요일

<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<html>
<head>
    <title>스프링 멀티 파일 업로드</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script>
<!-- jquery로 파일 첨부 추가 -->
$(document).ready(function() {

    //아래 File Add(id가 addFile인것)를 클릭시 id=fileview인 것의 아래에  <tr><td><input type="file... 추가, 파일을 더 입력할 수 있도록, 멀티파일 업로드가 가능하도록 추가
    $('#addFile').click(function() {
        var fileIndex = $('#fileview tr').children().length;      
        $('#fileview').append(
                '<tr><td>'+
                '   <input type="file" name="files['+ fileIndex +']" />'+
                '</td></tr>');
    });     
});
</script>
</head>
<body>
<h3>SpringMVC Muli File Upload example(oraclejavanew.kr)</h3>
 
<form:form method="post" action="save.html"
      modelAttribute="uploadForm" enctype="multipart/form-data">
 
    <input id="addFile" type="button" value="File Add" />
    <table id="fileview">
        <tr>
            <td><input name="files[0]" type="file" /></td>
        </tr>
        <tr>
            <td><input name="files[1]" type="file" /></td>
        </tr>
    </table>
    <br/><input type="submit" value="Upload" />
</form:form>
</body>
</html>


댓글 없음:

댓글 쓰기