viclafouch / mui-file-input

A file input designed for the React library MUI
https://viclafouch.github.io/mui-file-input/
MIT License
77 stars 17 forks source link

Filter file type is not working #29

Closed alexaung closed 1 year ago

alexaung commented 1 year ago

Describe the bug I only want to upload ".jpg, .jpeg, .png, .pdf"

But it is not filter. Is there a way?. I can't find it in document.

<Controller
          control={control}
          name="certificateOfIncorporation"
          render={({ field, fieldState }) => (
            <MuiFileInput
              className="mt-32"
              {...field}
              label="Certificate of incorporation"
              placeholder="Certificate of incorporation"
              id="certificateOfIncorporation"
              error={fieldState.invalid}
              helperText={fieldState.invalid ? "File is invalid" : ""}
              variant="outlined"
              fullWidth
              accept=".jpg, .jpeg, .png, .pdf" // add this line
            />
          )}
        />
viclafouch commented 1 year ago

Hello !

It's HTML here : https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept

alexaung commented 1 year ago

Actually, I have tied it with. Still not working. If I use input tag, it is working.

<Controller control={control} name="employeeIdCard" render={({ field, fieldState }) => ( <MuiFileInput className="mt-32" {...field} label={t("EMPLOYEE_ID_CARD")} placeholder={t("EMPLOYEE_ID_CARD")} id="employeeIdCard" error={fieldState.invalid} helperText={fieldState.error ? fieldState.error.message : ""} variant="outlined" required fullWidth accept="image/png, image/jpeg" /> )} />

alexaung commented 1 year ago

Sorry. My bad. it is working this way

inputProps={{ accept: "image/png, image/jpeg" }}