+++ ȨÁ¦ÀÛ ¹ÙÀ̺í +++
ȨÁ¦ÀÛ ¹ÙÀ̺í ÀÌ »çÀÌÆ®´Â ÀÌ¿µÂù´ÔÀÇ »çÀÌÆ®¸¦ º¹¿øÇÑ °ÍÀÔ´Ï´Ù.
Untitled Document
Html
Dhtml
Css
Php
Asp
Cgi
Java Script
Java Applet
Multimedia
Win Tip
ABCUpload¸¦ ÀÌ¿ëÇÑ °£´ÜÇÑ ÆÄÀϾ÷·Îµå
1. basicupload.html ¹®¼­¸¦ ´ÙÀ½°ú °°ÀÌ ¸¸µç´Ù.

<html>
<body>
<form method="post" action="basicupload.asp" enctype="multipart/form-data">
<input type="file" name="file"><br>
<input type="submit" name="submit" value="submit">
</form>
<body>
</html>


2. ºê¶ó¿ìÀú·Î À§¿¡¼­ ÀÛ¼ºÇÑ basicupload.html ¹®¼­¸¦ È®ÀÎÇÑ °á°ú´Â ´ÙÀ½°ú °°½À´Ï´Ù.



3. basicupload.asp ¹®¼­¸¸µé¶§´Â À§ÀÇ ¼Ò½ºÃ³·³ ´ÙÀ½ÀÇ »çÇ×À» ²À ÁöÄÑ¾ß ÇÕ´Ï´Ù.

<form method="post" action="basicupload.asp" enctype="multipart/form-data">


Æûű׸¦ ÀÌ¿ëÇÑ ÆÄÀϾ÷·Îµå½Ã¿¡´Â ¹Ýµå½Ã enctype="multipart/form-data"·Î ÁöÁ¤ÇØ¾ß ÇÕ´Ï´Ù.

±×¸®°í action="basicupload.asp" ºÎºÐÀº ½ÇÁ¦·Î ÆÄÀÏÀ» ¾÷·ÎµåÇÏ´Â ÀÏÀ» ó¸®ÇÏ´Â ¹®¼­¸¦ ÁöÁ¤ÇÏ´Â °ÍÀÔ´Ï´Ù.

Áö±Ý ¿ì¸®°¡ ÀÛ¼ºÇÑ ¹®¼­ basicupload.asp ¹®¼­´Â ´Ü¼øÇÏ°Ô À¥»ó¿¡¼­ ¿Ã¸± ÆÄÀÏÀ» ¼±ÅÃÇÏ°í Àü¼ÛÇϵµ·Ï ÇÏ´Â ÀÏÀ» º¸¿©ÁÖ´Â ¿ªÈ°¸¸ ÇÏ´Â °ÍÀÌ°í, ½ÇÁ¦·Î È­¸é¿¡¼­ ¼±ÅÃÇÑ ÆÄÀÏÀ» ó¸®ÇÏ´Â ¹®¼­°¡ ¹Ù·Î action ºÎºÐ¿¡¼­ ÁöÁ¤ÇÑ ¹®¼­ÀÔ´Ï´Ù.

4. ÀÚ ÀÌÁ¦ basicupload.html ¹®¼­¿¡¼­ ÁöÁ¤ÇÑ ¹®¼­ basicupload.asp ¹®¼­¸¦ ´Ù¸§°ú °°ÀÌ ÀÛ¼ºÇÕ´Ï´Ù.


<% @Language="VBScript" %>
<html>
<body>
<%
     Dim theForm,theField  
     Set theForm = Server.CreateObject("ABCUpload4.XForm")
     theForm.AbsolutePath = True
     Set theField = theForm("file")(1)
     If theField.FileExists Then
     theField.Save "C:\temp\" & theField.SafeFileName
       Response.Write "File uploaded..."
     Else
       Response.Write "No file uploaded..."
     End If
%>
</body>
</html>


5. basicupload.asp ¹®¼­ ¼³¸í

Dim theForm,theField


º¯¼ö·Î »ç¿ëÇÒ À̸§À» DimÀ¸·Î ¼±¾ðÇÑ°ÍÀÔ´Ï´Ù. - ÀÌ°Ç »ý·«Çصµ µÇÁö¸¸ º¯¼öÀÇ ¸í½ÃÀû¼±¾ð ¹æ¹ýÀ¸·Î º¯¼öÀÇ ¿ÀŸ¸¦ ÀâÀ»¶§ À¯¿ëÇÏ°Ô »ç¿ëµË´Ï´Ù. Ç×»ó º¯¼ö¸¦ ¾²±âÀü¿¡´Â ÀÌ·¸°Ô ¼±¾ðºÎÅÍ ÇÏ´Â ½À°üÀ» µéÀ̵µ·Ï ÇսôÙ.

Set theForm = Server.CreateObject("ABCUpload4.XForm")


¿ì¸®´Â ABCUpload ÄÄÆ÷³ÍÆ®¿¡¼­ Á¦°øÇÏ´Â °´Ã¼¸¦ ÀÌ¿ëÇؼ­ ÆÄÀÏÀ» ¾÷·Îµå ½Ãų ¿¹Á¤ÀÔ´Ï´Ù. ÀÌ°÷¿¡¼­ óÀ½ »ç¿ëµÇ´Â °´Ã¼´Â XForm À̶ó´Â ³ðÀε¥ ÀÌ ³ðÀº ÆûÀ» ´Ù·ê¶§ »ç¿ëµÇ´Â °´Ã¼¶ó°í »ý°¢ÇÏ½Ã¸é µË´Ï´Ù. Âü°í·Î ¸Å´º¾ó¿¡´Â ´ÙÀ½°ú °°ÀÌ ¾²¿© ÀÖ½À´Ï´Ù. (It handles forms encoded in multipart format as defined in RFC 1867.)

ASP ¿¡¼­´Â ³»À尴ü°¡ ¾Æ´Ï¸é »ç¿ë ÇÒ °´Ã¼ÀÇ ÀνºÅϽº°ªÀ» ¸ÕÀú ¾ò°í ÀÌ°É º¯¼ö¿¡ ´ã¾Æ »ç¿ëÇÏ´Â ¹æ¹ýÀ¸·Î °´Ã¼¸¦ »ç¿ëÇÏ°Ô µË´Ï´Ù. ±×·¯¹Ç·Î XForm °³Ã¼ÀÇ ÀνºÅϽº°ªÀ» ¾ò±â À§ÇÏ¿© ASP ³»À尴üÀÎ Server °´Ã¼ÀÇ CreateObject ¸Þ½îµå ¹æ¹ýÀ» ÀÌ¿ëÇÏ¿© ÀÌ°ÍÀ» º¯¼ö theForm À̶ó´Â ³Ñ¿¡°Ô XForm °´Ã¼ÀÇ ·¹ÆÛ·±½º°ªÀ» ³Ñ°ÜÁÖ´Â ¹æ¹ýÀÔ´Ï´Ù.

ÀÌÁ¦ ÀÌÈÄ¿¡´Â theForm À̶ó´Â º¯¼ö¸¦ »ç¿ëÇÏ¿© XForm À̶ó´Â °´Ã¼°¡ °¡Áö°í ÀÖ´Â ¿©·¯°¡Áö ¼ºÁúÀ» ¸ðµÎ ÀÌ¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

theForm.AbsolutePath = True


XForm °´Ã¼°¡ Á¦°øÇÏ´Â ¼Ó¼º AbsolutePath¸¦ ÁöÁ¤ÇÏ´Â ¹æ¹ýÀÔ´Ï´Ù. Àý´ë°æ·Î¸íÀ» »ç¿ëÇÒ°ÇÁö¸¦ ÁöÁ¤ÇÏ´Â Á¤µµ·Î ÀÌÇØÇÏ½Ã¸é µÇ°Ú½À´Ï´Ù. ¿©±â¼­´Â True¶ó´Â °ªÀ» ÁÖ¾úÀ¸´Ï±ñ ¸Õ ¼Ò¸®³Ä...±×·¸ÁÒ Àý´ë°æ·Î¸íÀ» ÀÌ¿ëÇÏ°Ú´Ù´Â ¶æÀÌÁÒ ¸Ó..

Set theField = theForm("file")(1)


¿©±â¼­ theForm("file")(1) ºÎºÐÀº basicupload.html ¹®¼­¿¡¼­ ÀÛ¼ºÇÑ Æûű×Áß¿¡ ÆÄÀÏÀ» ÁöÁ¤ÇÏ´Â ÀÔ·Ââ¿¡´Â C:\¾î¼±¸Àú¼±¸\ ¶ó´Â ½ÄÀ¸·Î ½ÇÁ¦·Î Ŭ¶óÀ̾ðÆ® ÄÄÇ»ÅÍ¿¡ ÀÖ´Â ÆÄÀÏÀÇ °æ·Î¸íÀ» Äõ¸®°ªÀ¸·Î º¸³À´Ï´Ù. À̶§ À̸§À» ÁöÁ¤Çؼ­ º¸³»´Âµ¥ ¿©±â¼­´Â "file" À̶ó°í ÁöÁ¤Çß½À´Ï´Ù. ÀÌ Äõ¸®°ªÀ» ¾ò´Â ¹æ¹ýÀÌ ¹Ù·Î theForm("file")(1) ÀÔ´Ï´Ù. Á¤È®ÇÑ Ç¥ÇöÀº ¾Æ´Ï°ÚÁö¸¸ ÀÌ Äõ¸®°ªÀÇ ·¹ÆÛ·±½º°ªÀ» ÀÌ¿ëÇÏ¿© XField¶ó´Â °´Ã¼¸¦ »ý¼ºÇÏ´Â ¹æ¹ýÀÔ´Ï´Ù.

If theField.FileExists Then
  theField.Save "C:\temp\" & theField.SafeFileName
  Response.Write "File uploaded..."
Else
  Response.Write "No file uploaded..."
End If


¿©±â¼­´Â Á¶°Ç¹®À» ÀÌ¿ëÇϴµ¥ Á¶°Ç¹®ÀÇ Âü°ÅÁþÆǴܹ®À¸·Î theField.FileExists À» »ç¿ëÇϴµ¥ Âü°í·Î theField´Â ¹Ù·Î À§¿¡¼­ ¿ì¸®°¡ »ý¼ºÇÑ XFieldÀε¥ ÀÌ ³ðÀº FileExists¶ó´Â ¼Ó¼ºÀ» °¡Áö°í ÀÖ½À´Ï´Ù. ÆÄÀÏÀÇ Á¸Àç¿©ºÎ¸¦ ÆÇ´ÜÇؼ­ ºÒ¸°°ªÀ¸·Î °ªÀ» °¡Áö°í ÀÖ½À´Ï´Ù. Áï ÆÄÀÏÀÌ ÀÖÀ¸¸é Âü, ¾øÀ¸¸é °ÅÁþÀÇ °ªÀ» °¡ÁöÁÒ.

¸¸¾à ÆÄÀÏÀÌ ÀÖÀ¸¸é theField.Save "C:\temp\" & theField.SafeFileName °¡ ½ÇÇàÀÌ µÇ°Ú½À´Ï´Ù. °ÅÁþÀ̸é ÀÌ ºÎºÐÀº ½ÇÇàÀÌ µÇÁö ¾Ê°ÚÁÒ? theField´Â ¸Þ½îµå·Î Save¸¦ °¡Áö°í Àִµ¥ ¸» ±×·¡µµ ÀúÀåÇÏ´Â °ÍÀÔ´Ï´Ù. Á¤È®ÇÑ Ç¥ÇöÀº theField.Save InPath ÀÔ´Ï´Ù. InPath ºÎºÐ¿¡¼­ ÁöÁ¤µÈ °Í¿¡ ÆÄÀÏÀ» ÀúÀåÇÏ´Â °ÍÀÔ´Ï´Ù.

¿©±â¼­´Â InPath ºÎºÐ¿¡ "C:\temp\" & theField.SafeFileName ¶ó°í Àû¾úÁÒ? theFiels.SafeFileName Àº basicupload.html ¹®¼­¿¡¼­ ÆÄÀÏ ¼±Åúκп¡¼­ ÁöÁ¤ÇÑ ÆÄÀÏÀÇ À̸§°ú È®ÀåÀÚ¸¸ °¡Áö°í ÀÖ½À´Ï´Ù. ±×·¯´Ï±ñ °æ·Î¸íÀÌ C\temp\¿Ã¸±ÆÄÀÏÀ̸§.È®ÀåÀÚ ÀÇ ÇüÅ°¡ µÇ°ÚÁÒ?

±×·¡¼­ ÁöÁ¤ÇÑ Æú´õ¿¡ °°Àº À̸§À¸·ÎµÈ ÆÄÀÏÀ» ÀúÀåÇÒ¼öÀÖ°Ô ÇØ ÁØ´ä´Ï´Ù.
Update : 2001/05/28 [µ¹¾Æ°¡±â]