The axios upload array array contains file objects

1. Describe the problem
requirements as above, and the backend interface needs my post format as follows:

{
    "type": "***",
    "list": [
        {
            "filename": "***",
            "filedata": File
        }
    ]
}

2. I have tried
I directly set content-type to application/x-www-form-urlencoded, but the data sent is not what the backend wants, so instead, multipart/form-data, finds that it can not correctly transmit data of type File
3. So when using axios, what should we do when we encounter this type of parameter passing?

Jan.24,2022

pass it through the form, such as

var form = new FormData();
//
//
form.append('filekey',files);
axios.post(url,form).then((data) => { // })

get the file source through the form, ha, how do you get the uploaded content!


I suggest we do it separately. First of all, the object you passed used to be [obj obj], but not json serialization, so that all backend receivers are like this, and the file type will be killed when json serialization, and the type does not match.
you can adjust the parameters with the backend, leaving a special field to connect with the file parameters, and the others are json data communication.
is probably
let params = new FormData ();
params.append ('file', this.simpleVideoFile); / / it doesn't matter if it is a file collection array, or it can be passed to the same field several times. The backend can distinguish it. You have to negotiate
params.append (' param', JSON.stringify (other parameters))

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3920f-44507.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3920f-44507.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?