{"id":679,"date":"2024-04-15T11:09:07","date_gmt":"2024-04-15T02:09:07","guid":{"rendered":"http:\/\/inwelly.com\/?p=679"},"modified":"2024-04-23T04:33:37","modified_gmt":"2024-04-22T19:33:37","slug":"javascript-jquery-php-%eb%8b%a4%ec%a4%91-%ed%8c%8c%ec%9d%bc-%ec%97%85%eb%a1%9c%eb%93%9c-%ea%b0%84%eb%8b%a8","status":"publish","type":"post","link":"https:\/\/inwelly.com\/?p=679","title":{"rendered":"JAVASCRIPT jQuery + PHP \ub2e4\uc911 \ud30c\uc77c \uc5c5\ub85c\ub4dc ( \uac04\ub2e8 )\u00a0"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>testa.html ------------------------------------------------------------------------------------ \n&lt;script>\n \n$('#upload').click(function() {\n    var filedata = document.getElementsByName(\"file\"),\n            formdata = false;\n    if (window.FormData) {\n        formdata = new FormData();\n    }\n    var i = 0, len = filedata.files.length, img, reader, file;\n \n    for (; i &lt; len; i++) \n\t{\n        file = filedata.files&#91;i];\n        if (window.FileReader) \n\t\t{\n            reader = new FileReader();\n            reader.onloadend = function(e) \n\t\t\t{\n                showUploadedItem(e.target.result, file.fileName);\n            };\n            reader.readAsDataURL(file);\n        }\n    }\n \n&lt;\/script>\n\n&lt;iframe name=\"my_iframe\" src=\"\" width=\"0\" height=\"0\" style=\"display:none\">&lt;\/iframe>\n&lt;form enctype=\"multipart\/form-data\" action=\".\/testb.html\" method=\"post\" name='myiframe' target=\"my_iframe\">\n \n&lt;table height=100%>\n\t&lt;tr>&lt;td>&lt;input type=\"file\" id=\"file&#91;]\" name='file&#91;]'>&lt;\/td>&lt;td>&lt;input type=\"file\" id=\"file&#91;]\" name='file&#91;]'>&lt;\/td>&lt;\/tr>\n\t&lt;tr>&lt;td height=8>&lt;\/td>&lt;\/tr>\n\t&lt;tr>&lt;td>&lt;input type=\"file\" id=\"file&#91;]\" name='file&#91;]'>&lt;\/td>&lt;td>&lt;input type=\"file\" id=\"file&#91;]\" name='file&#91;]'>&lt;\/td>&lt;\/tr>\n\t&lt;tr>&lt;td height=8>&lt;\/td>&lt;\/tr>\n\t&lt;tr>&lt;td>&lt;input type=\"file\" id=\"file&#91;]\" name='file&#91;]'>&lt;\/td>&lt;td>&lt;button class=\"add_more btn btn-xs btn-primary\">File Upload&lt;\/button>&lt;\/td>&lt;\/tr>\n\t&lt;tr>&lt;td height=8>&lt;\/td>&lt;\/tr>\n&lt;\/table>\n&lt;\/form>\n\n---------------------------------------------------------------------------------------------\ntestb.html -------------------------------------------------------------------------------\n\n&lt;?php\n \n$success_value = 0 ;\n\/\/ $filename = array();\nfor($i=0; $i&lt;count($_FILES&#91;'file']&#91;'name']); $i++){\n    $target_path = \"\/home\/..your account..\/images\/\";\n    $ext = explode('.', basename( $_FILES&#91;'file']&#91;'name']&#91;$i]));\n    $target_path = $target_path . md5(uniqid()) . \".\" . $ext&#91;count($ext)-1]; \n \n\t\tif(move_uploaded_file($_FILES&#91;'file']&#91;'tmp_name']&#91;$i], $target_path)) \n\t\t{\n                     echo \"$target_path &lt;br>\";\n\t\t} \n\t\telse\n\t\t{\n \n\t\t}\n}\n \n?><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":1251,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,5],"tags":[],"class_list":["post-679","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","category-php"],"_links":{"self":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=679"}],"version-history":[{"count":1,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/679\/revisions"}],"predecessor-version":[{"id":680,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/posts\/679\/revisions\/680"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=\/wp\/v2\/media\/1251"}],"wp:attachment":[{"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inwelly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}