1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
    <link href="uploadify.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
    <script src="jquery.uploadify.v2.1.0.js" type="text/javascript"></script>
    <script src="swfobject.js" type="text/javascript"></script>
    <script type="text/javascript">
        var flag = false; // 유효성 검사
        $(document).ready(function () {
            // Uploadify 파일 업로드 컨트롤 : Flash가 설치가 되어있어야 함
            $('#fileInput').uploadify({
                'uploader': 'uploadify.swf', // Uploadify 컨트롤 지정
                'script': 'uploadify.ashx'// 서버측 스크립트, ASP.NET, ASP, PHP, JSP
                'cancelImg': 'cancel.png',   // 취소 이미지
                'auto': false, // true면 파일선택시 바로 자동으로 업로드됨
                'folder': '/Uploads', // 업로드할 폴더 : 가상디렉터리 + 업로드폴더
                // 업로드 완료시 처리 :
                //     주요 속성은 http://www.uploadify.com/documentation/ 참고
                'onComplete': function (event, queueID, fileObj, response, data) {
                    $('#lblFile').append(
                    '<a href="/WebJQuery' + fileObj.filePath + '">'
                    + fileObj.name + '</a><br />
' + response + '<br />
');                                       
                },
                'onSelect': function (event, queueID, fileObj) {
                    if (fileObj.name != "") {
                        flag = true;
                    }
                }
            });
            // 버튼 클릭시 업로드
            $('#btn').click(function () {
                // 유효성 검사 후
                if (!flag)
                    alert("파일을 업로드하세요.");
                // 업로드
                $('#fileInput').uploadifyUpload();
            });
        });
    </script>
 
    <input id="fileInput" name="fileInput" type="file">
    <input type="button" id="btn" value="업로드">
    <div id="lblFile">
</div>

Posted by 파노카페
: