{"id":5774,"date":"2014-04-06T20:18:21","date_gmt":"2014-04-06T20:18:21","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/06\/no-data-received-from-_files-collection-of-common-programming-errors\/"},"modified":"2014-04-06T20:18:21","modified_gmt":"2014-04-06T20:18:21","slug":"no-data-received-from-_files-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/06\/no-data-received-from-_files-collection-of-common-programming-errors\/","title":{"rendered":"no data received from $_FILES-Collection of common programming errors"},"content":{"rendered":"<p>i&#8217;m using html5 dropzone for upload image with javascript<\/p>\n<pre><code>var dropZone = $('#dropZone'),\n    maxFileSize = 1000000,\n    img_id = 0;\n\n\/\/ \nif (typeof (window.FileReader) == 'undefined') {\n    dropZone.text('NO BROWSER SUPPORT!');\n    dropZone.addClass('error');\n}\n\n\/\/ \ndropZone[0].ondragover = function () {\n    dropZone.addClass('hover');\n    return false;\n};\n\n\/\/ \ndropZone[0].ondragleave = function () {\n    dropZone.removeClass('hover');\n    return false;\n};\n\n\/\/ \ndropZone[0].ondrop = function (event) {\n    event.preventDefault();\n    dropZone.removeClass('hover');\n    dropZone.addClass('drop');\n\n    var file = event.dataTransfer.files[0];\n\n    \/\/ \n    if (file.size &gt; maxFileSize) {\n        dropZone.text('SO BIG FILE!');\n        dropZone.addClass('error');\n        return false;\n    }\n\n    \/\/ \n    var xhr = new XMLHttpRequest();\n    xhr.upload.addEventListener('progress', uploadProgress, false);\n    xhr.onreadystatechange = stateChange;\n    xhr.open('POST', '\/admin\/admin.api.php');\n    xhr.setRequestHeader('X-FILE-NAME', file.name);\n    xhr.send(file);\n};\n\n\/\/ \nfunction uploadProgress(event) {\n    var percent = parseInt(event.loaded \/ event.total * 100);\n    dropZone.text('????????: ' + percent + '%');\n}\n\n\/\/ \nfunction stateChange(event) {\n    if (event.target.readyState == 4) {\n        if (event.target.status == 200) {\n            dropZone.text('SUCCESS!');\n        } else {\n            dropZone.text('FAIL!');\n            dropZone.addClass('error');\n        }\n    }\n\n}\n<\/code><\/pre>\n<p>Headers and data:<\/p>\n<pre><code>Request URL:http:\/\/***.com\/admin\/admin.api.php\nRequest Method:POST\nStatus Code:200 OK\nRequest Headersview source\nAccept:*\/*\nAccept-Encoding:gzip,deflate,sdch\nAccept-Language:uk-UA,uk;q=0.8,ru;q=0.6,en-US;q=0.4,en;q=0.2\nConnection:keep-alive\nContent-Length:86016\nContent-Type:image\/jpeg\nHost:***.com\nOrigin:http:\/\/***.com\nReferer:http:\/\/***.com\/admin\/\nUser-Agent:Mozilla\/5.0 (Windows NT 6.1) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/29.0.1547.62 Safari\/537.36\nX-FILE-NAME:image.jpeg\nResponse Headersview source\nConnection:Keep-Alive\nContent-Encoding:gzip\nContent-Length:132\nContent-Type:text\/html\nDate:Thu, 29 Aug 2013 19:29:00 GMT\nKeep-Alive:timeout=15, max=100\nServer:Apache\/2.2.16 (Debian)\nVary:Accept-Encoding\nX-Powered-By:PHP\/5.3.3-7+squeeze16\n<\/code><\/pre>\n<p>php script<\/p>\n<pre><code>    \n<\/code><\/pre>\n<p>returns<\/p>\n<p><code>Array()Array()Array()<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>i&#8217;m using html5 dropzone for upload image with javascript var dropZone = $(&#8216;#dropZone&#8217;), maxFileSize = 1000000, img_id = 0; \/\/ if (typeof (window.FileReader) == &#8216;undefined&#8217;) { dropZone.text(&#8216;NO BROWSER SUPPORT!&#8217;); dropZone.addClass(&#8216;error&#8217;); } \/\/ dropZone[0].ondragover = function () { dropZone.addClass(&#8216;hover&#8217;); return false; }; \/\/ dropZone[0].ondragleave = function () { dropZone.removeClass(&#8216;hover&#8217;); return false; }; \/\/ dropZone[0].ondrop = function [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5774","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5774"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5774\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}