티스토리 뷰

웹프로그래밍/ASP Classic

Batch file uploader

공허공자 2009. 3. 31. 12:00

[참고] http://mlmlml.yaekumo.com/MultiFileUpload/


mupload_form.htm
- 파일 업로드 폼

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
 
    <script src="prototype.js" type="text/javascript"></script>
    <script src="scriptaculous.js" type="text/javascript"></script>
 
    <style type="text/css">
    <!--
        #attachFileList{
            background-color: #E7F3F7;
            padding:10px;
            margin:0px;
            margin-bottom:10px;
        }
        #attachFileList li{
            list-style-type: none;
        }
 
        #savedFileList{
            background-color:#E1FFE1;
            padding:10px;
            margin-bottom:10px;
            border:0px solid white;
        }
 
 
        .attachedFile{
            background-color:#FFF;
            padding: 5px;
            font-size:smaller;
            cursor:pointer;
            margin-bottom:5px;
        }
 
        .deletableFile{
            cursor:pointer;
        }
 
        #attachmentRemover, #deletingList, .dropActive{
            border:1px dashed black;
            padding:10px;
            margin-bottom:10px;
        }
        .dropActive{
            background-color: #FFDAB5;
        }
 
        .gdsResults b{
            background-color: yellow;
        }
    -->
    </style>
 
</head>
 
<body>
 
    <form method="post" action="mupload.asp" enctype="multipart/form-data">
        <fieldset>
            <legend>Multi File Uploader</legend>
            <p></p>
            <div id="fileInputFrame">
                <input type="file">
                <input id="addAttachmentFile" value="attach this file" type="button">
            </div>
            <p></p>
            <ul id="attachFileList">
                <p>attached files will be shown here</p>
            </ul>
            <p></p>
            <div id="attachmentRemover" style="position: relative;">
drop any added files to delete</div>
 
            <input value="send all" type="submit">
        </fieldset>
    </form>
 
    <script language="javascript" type="text/javascript">
    //<![CDATA[
        //trash bin
        Droppables.add('attachmentRemover', {
            accept:'attachedFile',
            hoverclass:'dropActive',
            onDrop: function(element){
                element.parentNode.removeChild(element);
            }
        });
 
        //attach file button
        Event.observe("addAttachmentFile", "click", function(event){
            var thisInputFile = $A($("fileInputFrame").getElementsByTagName("input")).find(function(element, index){
                if(element.type.toLowerCase() == "file"){
                    return true;
                }
            });
 
            if(thisInputFile.value == ""){
                new Effect.Highlight(thisInputFile);
                Event.stop(event);
                return;
            }
 
            //input file element name////////////////
            thisInputFile.name = "attachedFiles[]";
            /////////////////////////////////////////
 
            Element.hide(thisInputFile);
            var li = Builder.node("li", {className: "attachedFile"}, thisInputFile.value);
 
            li.appendChild(thisInputFile);
 
            $("attachFileList").appendChild(li);
            new Draggable(li, {revert: true});
 
            new Insertion.Before("addAttachmentFile", "<input type='file'>  ");
 
        }, false);
    //]]>
    </script>
 
</body>
</html>

mupload.asp
- 파일 업로드를 처리

<%
'----------------------------------------------------------------------
' Upload backend process
'----------------------------------------------------------------------
Set Upload = Server.CreateObject("TABS.Upload")
Upload.Start Server.Mappath("./data")
Set uFiles = Upload.Form("attachedFiles[]")
'Response.Write(uFiles.count) : Response.End
For Each uFile In uFiles
	uFile.Save
Next

Set Upload = Nothing
%>


'웹프로그래밍 > ASP Classic' 카테고리의 다른 글

Ajax Upload  (0) 2009.04.01
ASP Xtreme Evolution Framework  (0) 2009.04.01
ASP XML DOM  (0) 2009.03.31
자바스크립트를 이용한 세션 자동 연결 종료 체킹  (0) 2009.03.26
ASP에서 XML 다루기 Microsoft.XMLDOM  (0) 2009.03.25
댓글