Qu'est-ce que Generateur d'input upload de dossier ?
The webkitdirectory attribute on an input type=file element lets users select an entire folder instead of individual files. When a folder is selected, the browser populates the input files FileList with all files from the selected directory and its subdirectories. Each file has a webkitRelativePath property that provides the path relative to the selected directory (for example, images/logo.png). The standardized directory attribute provides the same functionality across modern browsers.
Réponse rapide
Use input type=file with the webkitdirectory attribute to let users select entire folders for upload. Each file in the selected directory exposes a webkitRelativePath property showing its path relative to the chosen folder. Supported in Chrome 30+, Edge 12+, Safari 11.1+, and Firefox 50+. The generated HTML includes a drag-and-drop zone, file list display with directory tree view, and support for single-file, multiple-file, and directory modes.
Limites
- webkitRelativePath is only available for files selected through a directory picker -- files added via drag-and-drop from the operating system do not have path information in Firefox and Safari, though Chrome and Edge support directory drag-and-drop.
- Browser support for directory input is strong in Chromium-based browsers and Firefox but Safari's implementation has historically lagged. The standardized directory attribute is supported in Safari 17+ but older Safari versions require the webkitdirectory prefix.
- Large directory selections (thousands of files) can freeze the browser tab while the file list is being populated and displayed. Use lazy rendering or a Web Worker for production deployments handling large directories.
Comment utiliser cet outil
- Choose the upload mode: single file (one file at a time), multiple files (select several files), or directory (select an entire folder).
- Configure the drag-and-drop zone: enable or disable drag-and-drop support, customize the drop zone text and active state styling (border color, background, or overlay).
- Customize the file list display: show file names, sizes, types, and the webkitRelativePath for directory uploads. Toggle between a flat list and a tree view that preserves the directory structure.
- Copy the generated HTML with embedded CSS and JavaScript. The output includes a complete, self-contained file upload interface with event handling for the change event and drag-and-drop events.
A quoi il sert
- Build an upload interface for a documentation site that accepts entire folders of images or markdown files while preserving the directory structure.
- Create a bulk file upload tool for a CMS where editors drag and drop a folder of assets and the relative paths are used for URL mapping.
- Design a migration tool that accepts a folder of exported content and uses webkitRelativePath to reconstruct the original directory hierarchy on the server.