Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue #73 #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/components/Widget/FileWidget.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ const FileWidget = (props) => {
}
};
reader.readAsDataURL(files[0]);

/* add dummy file to input element,
to make sure the browsers form validation
recognizes this field as filled
*/
let inputEl = document.getElementById(`field-${id}`);
const myFile = new File([], file.name, {
type: 'text/plain',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as i understand, you are forcing the file mime_type. What appens if i upload a jpg, or png, or pdf or xls file for example? could you get mime type from file var?

lastModified: new Date(),
});
const dataTransfer = new DataTransfer();
dataTransfer.items.add(myFile);
inputEl.files = dataTransfer.files;
// help Safari out by setting the data-file attribute
if (inputEl.webkitEntries.length) {
inputEl.dataset.file = `${dataTransfer.files[0].name}`;
}
};

let attributes = {};
Expand Down