A simple component to handle a directory as a single file
import * as React from 'react';
import { ReactDirectoryZipInput } from 'react-directory-input';
function DirectoryUpload() {
const [isProcessing, setIsProcessing] = React.useState(false);
const [upload, setUpload] = React.useState<File | null>(null);
return (
<ReactDirectoryZipInput
onArchivingStart={() => {
setIsProcessing(true);
}}
onArchivingResult={({ result }) => {
setUpload(result);
setIsProcessing(false);
}}
/>
);
}
There is no way to manipulate state of file input from JavaScript for security reason, which is I didn't noticed when implementing it.
When to try using form, you should override default form submit handler to build your own FormData, or it is always empty file value.
MIT