{"id":2533,"date":"2009-02-06T04:49:17","date_gmt":"2009-02-06T04:49:17","guid":{"rendered":"http:\/\/dev.jblove.net\/?p=2533"},"modified":"2009-02-06T04:49:17","modified_gmt":"2009-02-06T04:49:17","slug":"%ed%8e%8c-%ea%b0%84%eb%8b%a8%ed%95%9c-%eb%a9%80%ed%8b%b0%ed%8c%8c%ec%9d%bc-%ec%97%85%eb%a1%9c%eb%8d%94","status":"publish","type":"post","link":"https:\/\/jblove.net\/?p=2533","title":{"rendered":"[\ud38c] \uac04\ub2e8\ud55c \uba40\ud2f0\ud30c\uc77c \uc5c5\ub85c\ub354"},"content":{"rendered":"<p>\uae30\ubcf8\uc801\uc778\ud2c0\uc740 \ucf54\ub4dc\ud504\ub85c\uc81d\ud2b8\uc5d0\uc11c \ub530\uc653\ub294\ub370&nbsp; \uc5b4\ub518\uc9c0 \uc798 \ubaa8\ub974\uac9f\ub124\uc694 <BR><BR>\uc2a4\ud06c\ub9bd\ud2b8 \ubd80\ubd84\ub9cc \uc870\uae08 \uc218\uc815 \ud588\uc2b5\ub2c8\ub2e4. <BR>\ud574\ub2f9 \uc704\uce58\uc5d0 uploads\ud3f4\ub354\ub97c \ub9cc\ub4e4\uc5b4 \uc918\uc57c \ud569\ub2c8\ub2e4. <BR><BR>\ucf54\ub4dc \ud504\ub85c\uc81d\ud2b8 \uc18c\uc2a4\uc5d0\uc11c \ud30c\uc77c \ucd94\uac00(+ \ubc84\ud2bc)\uc744 \ub204\ub974\uba74&nbsp; \uadf8\uc804\uc5d0 \uc788\ub358 \ud30c\uc77c\uba85\ub4e4\uc774 \uc0ac\ub77c\uc9c0\ub294 <BR>\ud604\uc0c1 \ub54c\ubb38\uc5d0&nbsp; \uadf8\ubd80\ubd84\ub9cc \uace0\uccd0\uc11c \uc62c\ub838\uc2b5\ub2c8\ub2e4. <BR><BR>\ucd5c\ub300 5\uac1c\uae4c\uc9c0 \uc5c5\ub85c\ub4dc \uac00\ub2a5 \uc785\ub2c8\ub2e4. <BR>\uae30\ubcf8\uc801\uc778 \uc635\uc158\ub4e4\uc740 \uc218\uc815 \ud558\uc154\uc11c \uc4f0\uc2dc\uba74 \ub420\ub4ef\ud569\ub2c8\ub2e4. ^^ <BR><BR>&lt;?php <BR><BR>if($_POST[&#8216;pgaction&#8217;]==&#8221;upload&#8221;) <BR>&nbsp; &nbsp; upload(); <BR>else <BR>&nbsp; &nbsp; uploadForm(); <BR><BR>\/\/The form having dynamic file uploader <BR>function uploadForm() { <BR>?&gt; <BR>&lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;&gt; <BR>&lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221;&gt; <BR>&lt;head&gt; <BR>&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text\/html; charset=euc-kr&#8221; \/&gt; <BR>&lt;title&gt; :: FILEUPLOAD :: &lt;\/title&gt; <BR>&lt;\/head&gt; <BR><BR>&lt;body bgcolor=&#8221;#C8C8C8&#8243; leftmargin=&#8221;0&#8243; topmargin=&#8221;0&#8243; rightmargin=&#8221;0&#8243; bottommargin=&#8221;0&#8243;&gt; <BR>&lt;br&gt; <BR>&lt;form name=&#8221;frm&#8221; method=&#8221;post&#8221; onsubmit=&#8221;return validate(this);&#8221; enctype=&#8221;multipart\/form-data&#8221;&gt; <BR>&lt;input type=&#8221;hidden&#8221; name=&#8221;pgaction&#8221;&gt; <BR>&nbsp; &nbsp; &lt;?php if ($GLOBALS[&#8216;msg&#8217;]) { echo &#8216;&lt;center&gt;&lt;span class=&#8221;err&#8221;&gt;&#8217;.$GLOBALS[&#8216;msg&#8217;].'&lt;\/span&gt;&lt;\/center&gt;&#8217;; }?&gt; <BR>&nbsp; &nbsp; &lt;input type=&#8217;button&#8217; value=&#8217;\ucd94\uac00&#8217; onclick=&#8217;appendItem()&#8217; \/&gt; <BR>&nbsp; &nbsp; &lt;div id=&#8217;itemList&#8217;&gt; <BR>&nbsp; &nbsp; &lt;input type=&#8221;file&#8221;&nbsp; name=&#8221;item_file[]&#8221;&gt; <BR>&nbsp; &nbsp; &lt;\/div&gt; <BR>&nbsp; &nbsp; &lt;input type=&#8221;submit&#8221; value=&#8221;Upload File&#8221;&gt; <BR>&nbsp; &nbsp; &lt;div id=&#8217;debug&#8217; style=&#8221;border:1px solid #000&#8243;&gt;&lt;\/div&gt; <BR><BR>&lt;\/form&gt; <BR>&lt;script type=&#8217;text\/javascript&#8217;&gt; <BR><BR>&nbsp; &nbsp; var count =0; <BR>&nbsp; &nbsp; function appendItem() <BR>&nbsp; &nbsp; {&nbsp; &nbsp;&nbsp; <BR>&nbsp; &nbsp; &nbsp; &nbsp; count++; <BR>&nbsp; &nbsp; &nbsp; &nbsp; if(count &gt; 5) <BR>&nbsp; &nbsp; &nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert(&#8220;\ub354\uc774\uc0c1\uc758 \ud30c\uc77c\uc744 \uc62c\ub9b4\uc218 \uc5c6\uc2b5\ub2c8\ub2e4.&#8221;); <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count = 5; <BR>&nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; &nbsp; &nbsp; else <BR>&nbsp; &nbsp; &nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/log(count); <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var newSpanItem = document.createElement(&#8220;div&#8221;); <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newSpanItem.setAttribute(&#8220;id&#8221;, &#8220;item_&#8221;+count); <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var msg_str = &#8216;&lt;input type=&#8221;file&#8221;&nbsp; name=&#8221;item_file[]&#8221;&gt;&#8217;+ &#8216;&lt;input type=&#8221;button&#8221; value =&#8221;\uc0ad\uc81c&#8221; onclick=&#8221;removeItem(&#8216;+count+&#8217;)&#8221;&gt; &#8216;; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/var msg_str =&#8221;ddd&lt;br&gt;&#8221;; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newSpanItem.innerHTML = msg_str; <BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var itemListNode = document.getElementById(&#8216;itemList&#8217;); <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; itemListNode.appendChild(newSpanItem); <BR>&nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; } <BR>&nbsp; &nbsp;&nbsp; <BR><BR>&nbsp; &nbsp; function removeItem(idCount) <BR>&nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; var item = document.getElementById(&#8220;item_&#8221;+ idCount); <BR>&nbsp; &nbsp; &nbsp; &nbsp; if(item != null) <BR>&nbsp; &nbsp; &nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; item.parentNode.removeChild(item); <BR>&nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; &nbsp; &nbsp; count &#8211;; <BR>&nbsp; &nbsp; } <BR><BR><BR>&nbsp; &nbsp; function validate(f) <BR>&nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; var chkFlg = false; <BR><BR>&nbsp; &nbsp; &nbsp; &nbsp; for(var i=0; i &lt; f.length; i++) <BR>&nbsp; &nbsp; &nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(f.elements[i].type==&#8221;file&#8221; &amp;&amp; f.elements[i].value != &#8220;&#8221;) <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chkFlg = true; <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; &nbsp; &nbsp; if(!chkFlg) <BR>&nbsp; &nbsp; &nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert(&#8216;Please browse\/choose at least one file&#8217;); <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return false; <BR>&nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; &nbsp; &nbsp; f.pgaction.value=&#8217;upload&#8217;; <BR>&nbsp; &nbsp; &nbsp; &nbsp; return true; <BR>&nbsp; &nbsp; } <BR>&lt;\/script&gt; <BR>&lt;\/body&gt; <BR>&lt;\/html&gt; <BR>&lt;?php <BR>} <BR><BR>\/\/function to store uploaded file <BR><BR>function upload(){ <BR>&nbsp; &nbsp;&nbsp; <BR>&nbsp; &nbsp; if(count($_FILES[&#8220;item_file&#8221;][&#8216;name&#8217;])&gt;0) <BR>&nbsp; &nbsp; { \/\/check if any file uploaded <BR>&nbsp; &nbsp; &nbsp; &nbsp; $GLOBALS[&#8216;msg&#8217;] = &#8220;&#8221;; \/\/initiate the global message <BR>&nbsp; &nbsp; &nbsp; &nbsp; for($j=0; $j &lt; count($_FILES[&#8220;item_file&#8221;][&#8216;name&#8217;]); $j++) { \/\/loop the uploaded file array <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $filen = $_FILES[&#8220;item_file&#8221;][&#8216;name&#8217;][&#8220;$j&#8221;]; \/\/file name <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $path = &#8216;uploads\/&#8217;.$filen; \/\/generate the destination path <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(move_uploaded_file($_FILES[&#8220;item_file&#8221;][&#8216;tmp_name&#8217;][&#8220;$j&#8221;],$path)) { \/\/upload the file <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $GLOBALS[&#8216;msg&#8217;] .= &#8220;File# &#8220;.($j+1).&#8221; ($filen) uploaded successfully&lt;br&gt;&#8221;; \/\/Success message <BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; &nbsp; &nbsp; } <BR>&nbsp; &nbsp; } <BR>&nbsp; &nbsp; else <BR>&nbsp; &nbsp; { <BR>&nbsp; &nbsp; &nbsp; &nbsp; $GLOBALS[&#8216;msg&#8217;] = &#8220;No files found to upload&#8221;; \/\/Failed message &nbsp; &nbsp; <BR>&nbsp; &nbsp; } <BR>&nbsp; &nbsp;&nbsp; <BR>&nbsp; &nbsp; uploadForm(); \/\/display the main form <BR>} <BR>?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uae30\ubcf8\uc801\uc778\ud2c0\uc740 \ucf54\ub4dc\ud504\ub85c\uc81d\ud2b8\uc5d0\uc11c \ub530\uc653\ub294\ub370&nbsp; \uc5b4\ub518\uc9c0 \uc798 \ubaa8\ub974\uac9f\ub124\uc694 \uc2a4\ud06c\ub9bd\ud2b8 \ubd80\ubd84\ub9cc \uc870\uae08 \uc218\uc815 \ud588\uc2b5\ub2c8\ub2e4. \ud574\ub2f9 \uc704\uce58\uc5d0 uploads\ud3f4\ub354\ub97c \ub9cc\ub4e4\uc5b4 \uc918\uc57c \ud569\ub2c8\ub2e4. \ucf54\ub4dc \ud504\ub85c\uc81d\ud2b8 \uc18c\uc2a4\uc5d0\uc11c \ud30c\uc77c \ucd94\uac00(+ \ubc84\ud2bc)\uc744 \ub204\ub974\uba74&nbsp; \uadf8\uc804\uc5d0 \uc788\ub358 \ud30c\uc77c\uba85\ub4e4\uc774 \uc0ac\ub77c\uc9c0\ub294 \ud604\uc0c1 \ub54c\ubb38\uc5d0&nbsp; \uadf8\ubd80\ubd84\ub9cc \uace0\uccd0\uc11c \uc62c\ub838\uc2b5\ub2c8\ub2e4. \ucd5c\ub300 5\uac1c\uae4c\uc9c0 \uc5c5\ub85c\ub4dc \uac00\ub2a5 \uc785\ub2c8\ub2e4. \uae30\ubcf8\uc801\uc778 \uc635\uc158\ub4e4\uc740 \uc218\uc815 \ud558\uc154\uc11c \uc4f0\uc2dc\uba74 \ub420\ub4ef\ud569\ub2c8\ub2e4. ^^ &lt;?php if($_POST[&#8216;pgaction&#8217;]==&#8221;upload&#8221;) &nbsp; &nbsp; upload(); else &nbsp; &nbsp; uploadForm(); \/\/The [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[51],"tags":[402,448,449],"class_list":["post-2533","post","type-post","status-publish","format-standard","hentry","category-papa-php","tag-php","tag-448","tag-449"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts\/2533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2533"}],"version-history":[{"count":0,"href":"https:\/\/jblove.net\/index.php?rest_route=\/wp\/v2\/posts\/2533\/revisions"}],"wp:attachment":[{"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jblove.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}