I'm using:
<ReactFileReader handleFiles={this._getFiles}>
<button className='btn'>Upload</button>
</ReactFileReader>
On an spfx web part. It's a form that submits to an SPO list but I want a file to be attached to the list item. I've tried lots of other solutions but my knowledge is lacking on how to implement them. Finding the wrapper has made things potentially easier but I'm still clueless on how to set the upload to state. What type should the state item be initialised as? [], "", or null
Is there anything else I should know? Here is my function for the file upload:
private _getFiles = files => {
const content = files.result;
console.log('file content:', content);
this.setState({
FileUpload: files
}, () => {
console.log(this.state.FileUpload);
});
console.log(files);
}
In the console I'm getting [object FileLest]: 0: File, length: 1} but it reads out the title of the document that I've 'attached'. I've read this but I need it distilled into a basic code example: How to set file object in state with React hooks?
It's not setting anything to state though.
I suppose this is a start?