I am having a file upload using Antd design and it makes the file upload fine.
<Upload {...props}>
<Button icon={<UploadOutlined />}>Upload png only</Button>
</Upload>
Here I have a beforeUplaod function and its code looks like,
const beforeUpload = (file) => {
const isPNG = file.type === "image/png";
if (!isPNG) {
message.error(`${file.name} is not a png file`);
}
// return Upload.LIST_IGNORE; (This will work in newer version but I am using older one which is 4.9.4.
}
As I have mentioned in the above code, if the uploaded image is not png then it will remove the uploaded one from current list as we use Upload.LIST_IGNORE but unfortunately I am working in a older version 4.9.4 and it doesn't have any such keyword to remove the inValid upload from the list.
Could you please kindly help me to remove the uploaded invalid item from the list for version 4.9.4?
Working example:
Result:
After some try, I have prevented the file to display in the list if it is not valid but unfortunately the delete of the uploaded file doesn't work now (which was working fine before this current implementation).


Upload.LIST_IGNOREis documented as more a "hack" to safely merge/ignore files being uploaded. I don't see any such logic in 4.9.4. I'm unfamiliar with AntD and this specific component, but I'm gathering this is effectively a validation function. Based on the v4.9.4 logic have you tried returningtruefor files that aren't valid?return truefor invalid file but I couldn't see it prevents from uploading to the list, codesandbox.io/s/…