directoryfasthtmlwebkitdirectory

FastHTML, how to add the webkitdirectory property to a Input element to get a folder name?


I want to get this raw html using FastHTML components (in order to obtain a folder name):

<input type="file" webkitdirectory />

I have tried this with the help of https://h2f.answer.ai/:

Input( type="file", webkitdirectory="")

But the property webkitdirectory is not included in the html that is generated. The code generated is

<input type="file" />

Solution

  • Set the attribute to True to include the attribute name in the HTML output:

    Input(type='file', webkitdirectory=True)