{"action":"created","issue":{"url":"https://api.github.com/repos/php-fig/fig-standards/issues/492","labels_url":"https://api.github.com/repos/php-fig/fig-standards/issues/492/labels{/name}","comments_url":"https://api.github.com/repos/php-fig/fig-standards/issues/492/comments","events_url":"https://api.github.com/repos/php-fig/fig-standards/issues/492/events","html_url":"https://github.com/php-fig/fig-standards/pull/492","id":66887473,"number":492,"title":"Added UploadedFileInterface","user":{"login":"webmozart","id":176399,"avatar_url":"https://avatars.githubusercontent.com/u/176399?v=3","gravatar_id":"","url":"https://api.github.com/users/webmozart","html_url":"https://github.com/webmozart","followers_url":"https://api.github.com/users/webmozart/followers","following_url":"https://api.github.com/users/webmozart/following{/other_user}","gists_url":"https://api.github.com/users/webmozart/gists{/gist_id}","starred_url":"https://api.github.com/users/webmozart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webmozart/subscriptions","organizations_url":"https://api.github.com/users/webmozart/orgs","repos_url":"https://api.github.com/users/webmozart/repos","events_url":"https://api.github.com/users/webmozart/events{/privacy}","received_events_url":"https://api.github.com/users/webmozart/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-04-07T13:46:10Z","updated_at":"2015-04-08T21:47:13Z","closed_at":"2015-04-08T21:25:52Z","pull_request":{"url":"https://api.github.com/repos/php-fig/fig-standards/pulls/492","html_url":"https://github.com/php-fig/fig-standards/pull/492","diff_url":"https://github.com/php-fig/fig-standards/pull/492.diff","patch_url":"https://github.com/php-fig/fig-standards/pull/492.patch"},"body":"The structure of PHP's $_FILES array is inconsistent with the structure of $_POST when the names of the form fields contain array keys.\r\n\r\nFor example, when submitting the text inputs \"text[0]\" and \"text[1]\", the contents of $_POST are:\r\n\r\n```\r\narray(1) { \r\n    [\"text\"]=>array(2) { \r\n        [0]=>string(5)\"text0\" \r\n        [1]=>string(5)\"text1\" \r\n    } \r\n} \r\n```\r\n\r\nHowever, when submitting the file inputs \"file[0]\" and \"file[1]\", the contents of $_FILES are:\r\n\r\n```\r\narray(1) { \r\n    [\"file\"]=>array(2) { \r\n        [\"name\"]=>array(2) { \r\n            [0]=>string(9)\"file0.txt\" \r\n            [1]=>string(9)\"file1.txt\" \r\n        } \r\n        [\"type\"]=>array(2) { \r\n            [0]=>string(10)\"text/plain\" \r\n            [1]=>string(10)\"text/html\" \r\n        } \r\n    } \r\n} \r\n```\r\n\r\nWhile you can read `$_POST['text'][1]` to access the contents of the field \"text[1]\", you *cannot* read `$_FILES['file'][1]` to access the contents of the field \"file[1]\", which is a quite big usability issue in practice. Symfony, for example, rearranges the contents of the $_FILES array for that sake.\r\n\r\nI think PSR-7 should fix this issue. Otherwise every user of the PSR interfaces must fix this themselves, which isn't exactly interoperable.\r\n\r\nI see two approaches to fix this:\r\n\r\n* Describe this issue and the precise rules for rearranging the array in the PSR. This is verbose and prone to mistakes, which is why I don't like it very much.\r\n* Enforce implementations to return `UploadedFileInterface` objects \"in the same structure\" as the $_FILES array (same wording as in getQueryParams()). This solution is concise and leaves little room for interpretation. The correct result in the above case would be:\r\n\r\n```\r\narray(1) { \r\n    [\"file\"]=>array(2) { \r\n        [0]=>object(UploadedFileInterface)\r\n        [1]=>object(UploadedFileInterface)\r\n    } \r\n} \r\n```\r\n\r\nHence it is possible to read `$message->getUploadedFiles()['file'][1]` to access all data related to the field \"file[1]\"."},"comment":{"url":"https://api.github.com/repos/php-fig/fig-standards/issues/comments/91045372","html_url":"https://github.com/php-fig/fig-standards/pull/492#issuecomment-91045372","issue_url":"https://api.github.com/repos/php-fig/fig-standards/issues/492","id":91045372,"user":{"login":"webmozart","id":176399,"avatar_url":"https://avatars.githubusercontent.com/u/176399?v=3","gravatar_id":"","url":"https://api.github.com/users/webmozart","html_url":"https://github.com/webmozart","followers_url":"https://api.github.com/users/webmozart/followers","following_url":"https://api.github.com/users/webmozart/following{/other_user}","gists_url":"https://api.github.com/users/webmozart/gists{/gist_id}","starred_url":"https://api.github.com/users/webmozart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webmozart/subscriptions","organizations_url":"https://api.github.com/users/webmozart/orgs","repos_url":"https://api.github.com/users/webmozart/repos","events_url":"https://api.github.com/users/webmozart/events{/privacy}","received_events_url":"https://api.github.com/users/webmozart/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T21:47:12Z","updated_at":"2015-04-08T21:47:12Z","body":"> Having $_FILES diverge from that removes interoperability with existing libraries\r\n\r\nI don't understand this argument. How can existing \"interoperability with existing libraries\" be an argument in a PSR that has not even been published?\r\n\r\n> If desired, I can open a pull request to outline that decision in the meta document.\r\n\r\nThat would be wise."}}