Javascript axios对post方法的调用未传递字符串数组,其传递不正确-React

Javascript axios对post方法的调用未传递字符串数组,其传递不正确-React,javascript,reactjs,asp.net-web-api,axios,Javascript,Reactjs,Asp.net Web Api,Axios,在我的React应用程序中,我使用axios调用api post方法,post方法有两个参数,一个参数是字符串,第二个参数是字符串数组,左边的第一个参数是字符串,它被正确地传递给api,但字符串数组没有被传递,谁能检查一下,告诉我有什么问题吗?提前谢谢 handleDownload = (e) => { e.preventDefault(); var formData = new FormData(); formData.append('community

在我的React应用程序中,我使用axios调用api post方法,post方法有两个参数,一个参数是字符串,第二个参数是字符串数组,左边的第一个参数是字符串,它被正确地传递给api,但字符串数组没有被传递,谁能检查一下,告诉我有什么问题吗?提前谢谢

    handleDownload = (e) => {
    e.preventDefault();

    var formData = new FormData();
    formData.append('communityname', this.state.selectedCommunity);
    formData.append('files', this.state.files);

    axios({
        method: 'post',
        url: clientConfiguration['filesApi.local'],
        data: formData
    });
}
我的API方法如下:

        [HttpPost]
    public FileContentResult Post([FromForm] string communityName, [FromForm] string[] files) 
    {           
        string rootPath = Configuration.GetValue<string>("ROOT_PATH");
        string communityPath = rootPath + "\\" + communityName;

        byte[] theZipFile = null;

        using (MemoryStream zipStream = new MemoryStream())
        {
            using (ZipArchive zip = new ZipArchive(zipStream, ZipArchiveMode.Create, true))
            {
                foreach (string attachment in files)
                {
                    var zipEntry = zip.CreateEntry(attachment);

                    using (FileStream fileStream = new FileStream(communityPath + "\\" + attachment, FileMode.Open))
                    using (Stream entryStream = zipEntry.Open())
                    {
                        fileStream.CopyTo(entryStream);
                    }
                }
            }
            theZipFile = zipStream.ToArray();
        }

        return File(theZipFile, "application/zip", communityName + ".zip");
    }
[HttpPost]
public FileContentResult Post([FromForm]string communityName,[FromForm]string[]files)
{           
字符串rootPath=Configuration.GetValue(“根路径”);
字符串communityPath=rootPath+“\\”+communityName;
字节[]theZipFile=null;
使用(MemoryStream zipStream=新的MemoryStream())
{
使用(ZipArchive zip=new ZipArchive(zipStream,ZipArchiveMode.Create,true))
{
foreach(文件中的字符串附件)
{
var zipEntry=zip.CreateEntry(附件);
使用(FileStream FileStream=newfilestream(communityPath+“\\”+附件,FileMode.Open))
使用(Stream entryStream=zipEntry.Open())
{
CopyTo(entryStream);
}
}
}
ZipFile=zipStream.ToArray();
}
返回文件(ZipFile,“application/zip”,communityName+“.zip”);
}

我得到的文件参数值如下,客户端脚本将文件作为一个字符串发布为“[对象对象],[对象对象],[对象对象],[对象对象对象],[对象对象对象]”,而不是单独的数组字符串,任何帮助都请提前感谢。

也许这样效果更好

    handleDownload = (e) => {
    e.preventDefault();

    var formData = new FormData();
    formData.append('communityname', this.state.selectedCommunity);
    formData.append('files', this.state.files);

    axios({
        method: 'post',
        url: clientConfiguration['filesApi.local'],
        data: formData
    });
}
    let url = clientConfiguration['filesApi.local'];
    let data = formData
    axios.post(url, {data});

我希望它能起作用

不,它不起作用我的朋友我尝试了以下两种方法:handleDownload=(e)=>{e.preventDefault();var formData=new formData();formData.append('communityname',this.state.selectedCommunity);formData.append('files',this.state.files);let url=clientConfiguration['filesApi.local'];//axios.post(url,{formData});axios({method:'post',url:url,data:{formData});}仍然不能这样工作-有什么帮助吗,我的朋友