{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/9281","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/9281/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/9281/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/9281/events","html_url":"https://github.com/yiisoft/yii2/issues/9281","id":98628565,"number":9281,"title":"File doesn't uploading, if it is empty","user":{"login":"BooleanType","id":10816818,"avatar_url":"https://avatars.githubusercontent.com/u/10816818?v=3","gravatar_id":"","url":"https://api.github.com/users/BooleanType","html_url":"https://github.com/BooleanType","followers_url":"https://api.github.com/users/BooleanType/followers","following_url":"https://api.github.com/users/BooleanType/following{/other_user}","gists_url":"https://api.github.com/users/BooleanType/gists{/gist_id}","starred_url":"https://api.github.com/users/BooleanType/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BooleanType/subscriptions","organizations_url":"https://api.github.com/users/BooleanType/orgs","repos_url":"https://api.github.com/users/BooleanType/repos","events_url":"https://api.github.com/users/BooleanType/events{/privacy}","received_events_url":"https://api.github.com/users/BooleanType/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-02T19:02:54Z","updated_at":"2015-08-02T19:51:29Z","closed_at":null,"body":"I have rules:\r\n\r\n`return [\r\n            [['docFile'], 'file', 'skipOnEmpty' => false, 'extensions' => 'docx, doc, txt'],\r\n ];`\r\n\r\nIt's OK, if file is not empty. But if it is, Yii2 throws validation error. E.g., if extension of empty file is 'docx', it displays `'Only files with these extensions are allowed: docx, doc, txt.'` I found, that `FileValidator::validateExtension()` return `false`, cause this conditions fulfills:\r\n\r\n`if (!in_array($extension, $extensionsByMimeType, true)) {\r\n         return false;\r\n }`\r\n\r\n`$mimeType` in this case is `inode/x-empty`.\r\n\r\nWhat can I do with this?"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/127061824","html_url":"https://github.com/yiisoft/yii2/issues/9281#issuecomment-127061824","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/9281","id":127061824,"user":{"login":"BooleanType","id":10816818,"avatar_url":"https://avatars.githubusercontent.com/u/10816818?v=3","gravatar_id":"","url":"https://api.github.com/users/BooleanType","html_url":"https://github.com/BooleanType","followers_url":"https://api.github.com/users/BooleanType/followers","following_url":"https://api.github.com/users/BooleanType/following{/other_user}","gists_url":"https://api.github.com/users/BooleanType/gists{/gist_id}","starred_url":"https://api.github.com/users/BooleanType/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BooleanType/subscriptions","organizations_url":"https://api.github.com/users/BooleanType/orgs","repos_url":"https://api.github.com/users/BooleanType/repos","events_url":"https://api.github.com/users/BooleanType/events{/privacy}","received_events_url":"https://api.github.com/users/BooleanType/received_events","type":"User","site_admin":false},"created_at":"2015-08-02T19:51:29Z","updated_at":"2015-08-02T19:51:29Z","body":"In current project it is not necessary, but what if I am a teacher and need to send just file sctructure (tabs, indents, etc.), in a students portal without any text? In source code I found, that checking MIME-type and ext is in the same function. If they were separated, the problem would disappear. But, maybe, u are right and it is not so great problem, which need resolving... :)"}}