{"id":2998,"date":"2022-11-09T16:53:03","date_gmt":"2022-11-09T15:53:03","guid":{"rendered":"https:\/\/ekiwi.de\/?p=2998"},"modified":"2022-11-09T16:53:10","modified_gmt":"2022-11-09T15:53:10","slug":"php-datei-wird-nicht-hochgeladen-dateigroesse-0","status":"publish","type":"post","link":"https:\/\/ekiwi.de\/index.php\/2998\/php-datei-wird-nicht-hochgeladen-dateigroesse-0\/","title":{"rendered":"PHP: Datei wird nicht hochgeladen, Dateigr\u00f6\u00dfe = 0"},"content":{"rendered":"<p>Fehler beim Dateiupload mit PHP. Die Datei ist zwar im $_FILES Array, aber die Dateigr\u00f6\u00dfe ist 0.<\/p>\n<p><!--more--><\/p>\n<p>Heute hatte ich ein interessantes PHP-Problem. Es ging um einen Dateiupload, der zwar augenscheinlich funktionierte, bzw. im Array $_FILES landete. Allerdings ohne Inhalt, die Dateigr\u00f6\u00dfe wurde mit 0 angeben.<\/p>\n<pre>\r\nvar_dump($_FILES);\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2022\/11\/php_upload_1.png\" alt=\"\" width=\"349\" height=\"303\" class=\"alignnone size-full wp-image-2999\" srcset=\"\/wp-content\/uploads\/2022\/11\/php_upload_1.png 349w, \/wp-content\/uploads\/2022\/11\/php_upload_1-300x260.png 300w\" sizes=\"auto, (max-width: 349px) 100vw, 349px\" \/><\/p>\n<p>Irgendetwas muss wohl schiefgelaufen sein. In diesem Fall hilft es sich die anderen Werte im Array anzuschauen, speziell  den &#8222;error&#8220;. Hier gibt PHP den Grund f\u00fcr den Fehler an. Sofern der Wert &#8222;0&#8220; ist, ist alles in Ordnung.<\/p>\n<p>In meinem Fall stand dort die &#8222;1&#8220;. Ein Blick in die <a href=\"https:\/\/www.php.net\/manual\/en\/features.file-upload.errors.php\" target=\"_blank\" rel=\"noopener\">Fehlerliste<\/a> gibt Aufschluss \u00fcber den Fehler:<\/p>\n<pre>\r\nUPLOAD_ERR_INI_SIZE\r\n\tValue: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini. \r\n<\/pre>\n<p>Ein kurzer Blick in die phpinfo-Datei und siehe da, der Upload war auf 2 MB begrenzt. Die L\u00f6sung ist also den Wert in der PHP-Konfiguration zu erh\u00f6hen.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/wp-content\/uploads\/2022\/11\/php_upload_2.png\" alt=\"\" width=\"411\" height=\"63\" class=\"alignnone size-full wp-image-3000\" srcset=\"\/wp-content\/uploads\/2022\/11\/php_upload_2.png 411w, \/wp-content\/uploads\/2022\/11\/php_upload_2-300x46.png 300w\" sizes=\"auto, (max-width: 411px) 100vw, 411px\" \/><\/p>","protected":false},"excerpt":{"rendered":"<p>Fehler beim Dateiupload mit PHP. Die Datei ist zwar im $_FILES Array, aber die Dateigr\u00f6\u00dfe ist 0.<\/p>\n","protected":false},"author":1,"featured_media":2228,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[14,13],"tags":[31],"class_list":["post-2998","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","category-programmierung","tag-php"],"_links":{"self":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/2998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/comments?post=2998"}],"version-history":[{"count":0,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/posts\/2998\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media\/2228"}],"wp:attachment":[{"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/media?parent=2998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/categories?post=2998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ekiwi.de\/index.php\/wp-json\/wp\/v2\/tags?post=2998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}