The requirement is that after the selected file is uploaded successfully, the status can be reset to “No file selected”. Baidu has not found a circle of practical and useful operation, or Google has the effect,

You can do this by providing a key value to the input

const fileRef = useRef<Input | null> (null)
const [fileInputKey, setFileInputKey] = useState('file')

// Import the method
const toImport = () = > {
    // Get the file
    constfile = fileRef.current.input? .files[0]
    if(file) {
        const formData = new FormData();
        formData.append('file', file)
        
        jiekou(formData).then(res= > {
            // After the interface is successfully accessed
            setFileInputKey(`fileThe ${new Date()}`)})}else {
        message.info('Please select file')}}Copy the code
 <Input
  ref={fileRef}
  type="file"
  id="XLS_FILE"
  name="XLS_FILE"
  accept=".xls"
  style={{ width: 250 }}
  key={fileInputKey}
/>
Copy the code

# How to reset input[type=file] after form submission?