RESOLVED FIXED271705
iOS: <input type="file" webkitdirectory> doesn't work.
https://bugs.webkit.org/show_bug.cgi?id=271705
Summary iOS: <input type="file" webkitdirectory> doesn't work.
Daniel Jacobs
Reported 2024-03-26 06:57:21 PDT
Attachments
Alexey Proskuryakov
Comment 1 2024-03-26 13:03:58 PDT
Looks like this is the only code we have referencing this attribute: // As of Sept 2017, Chrome and Firefox both only populate webkitEntries when the webkitdirectory flag is unset. // We do the same for consistency. if (input.hasAttributeWithoutSynchronization(webkitdirectoryAttr)) return { }; Weird that it got documented somewhere, and even specced.
Karl Dubost
Comment 2 2024-03-26 20:12:33 PDT
webkitdirectory was implemented in Gecko (Firefox) on June 2016 https://bugzilla.mozilla.org/show_bug.cgi?id=1258489 This was implemented for compatibility reasons with *Chrome* (when Chrome was using webkit) for websites like mega.nz in the past. There was at the time a spec issue opened on the compat spec. https://github.com/whatwg/compat/issues/54 It was eventually added to the File and Directory Entries API, Draft Community Group Report, which is not on the W3C standard track https://wicg.github.io/entries-api/#html-forms The document is clear > NOTE: The APIs described by this document was initially implemented in Google Chrome. Other browsers (at this time: Edge, Firefox and Safari) are starting to support subsets of Chrome’s APIs and behavior. The intent of this document is to specify the common subset to ensure that the implementations are interoperable. This is also in WebKit code. https://searchfox.org/mozilla-central/rev/fb2ad9ca7150890da5cadc458acdd10c87fd9a12/dom/html/HTMLInputElement.h#712-714 In addition to Safari on iOS (this bug), note that this is not available on Firefox Android. I don't remember seeing anything recently about spec work around directly uploads.
Radar WebKit Bug Importer
Comment 3 2024-03-26 20:28:26 PDT
Aditya Keerthi
Comment 4 2024-03-26 20:38:02 PDT
Just to correct Alexey's comment, as that is not the only use of the attribute. The important use is here: ``` bool FileInputType::allowsDirectories() const { ASSERT(element()); if (!element()->document().settings().directoryUploadEnabled()) return false; return element()->hasAttributeWithoutSynchronization(webkitdirectoryAttr); } ``` Which is set on `FileChooserSettings`. However, we are currently not reading the bit, and have not yet implemented the feature on iOS.
Lily Spiniolas
Comment 5 2024-10-03 21:30:52 PDT
EWS
Comment 6 2024-10-04 09:34:22 PDT
Committed 284685@main (ca350c23acde): <https://commits.webkit.org/284685@main> Reviewed commits have been landed. Closing PR #34675 and removing active labels.
Daniel Jacobs
Comment 7 2025-03-24 07:53:02 PDT
Are you sure this is working? Is it working on iOS 18.3? If not, what version of iOS supports or will support it? I tested https://codepen.io/danieljacobs/pen/VwodKYg with a device using iOS 18.3 and was not able to select a directory, just a file.
Daniel Jacobs
Comment 8 2025-03-24 07:56:24 PDT
That codepen works on Chrome on Android and every desktop browser I've tried, and https://bugzilla.mozilla.org/show_bug.cgi?id=1887878 is open to support it on Firefox on Android.
Alexey Proskuryakov
Comment 9 2025-03-24 14:54:05 PDT
This should be fixed in iOS 18.4 beta. Please let us know how it goes for you!
Note You need to log in before you can comment on or make changes to this bug.