Append related question

Hello,

In this example:

onFileUpload = async () => {

        const formData = new FormData();

        formData.append(
            "ImageData.File",
            this.state.selectedFile,
            this.state.selectedFile.name
        );

And here is ViewModel:

namespace imageEditor3
{
    public class ImageData
    {

        public string Description { get; set; }
        public IFormFile File { get; set; }
    }
}

As you can see wh have just defined one variable for “File” and we use it as the first parameter in the append, but how is it possible to define two values for it:

this.state.selectedFile,
            this.state.selectedFile.name

The code works well. How is it possible?

thanks,
Saeed

When in doubt what a JavaScript method does (and which parameters it takes), consult the documentation:

https://developer.mozilla.org/en-US/docs/Web/API/FormData/append

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.