Aurelia js fie上传至服务器

Aurelia js fie上传至服务器,aurelia,Aurelia,嗨,我是aurelia js的新手,我需要将文件上传到服务器,我正在使用autrelia js、Materialiecss和httpClient.fetch进行api调用。我不知道如何将文件发送到服务器 视图: <input type="file" files.bind="selectedFiles" change.delegate="onSelectFile($event)"> httpservice: return this.httpClient.fetch('http:/

嗨,我是aurelia js的新手,我需要将文件上传到服务器,我正在使用autrelia js、Materialiecss和httpClient.fetch进行api调用。我不知道如何将文件发送到服务器

视图:

<input type="file"  files.bind="selectedFiles" change.delegate="onSelectFile($event)">
httpservice:

 return this.httpClient.fetch('http://api.dmsapp.tk/'+url,
            {
                method: method,
                body : json(myPostData),
                headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'authorization': this.authorization}})
            .then(response => response.json());

正在寻找解决方案。

如果是一个文件,而您正试图上载特定的媒体类型, 标题“内容类型”:“application/x-www-form-urlencoded”对我来说似乎不合适。请在此处查看相应的媒体类型:

另外,将数据序列化为JSON,如果数据是二进制的,则需要将其更改为字节数组

您可以在此处找到一些有用的信息:


另外,如果您在URL和标题中都设置了令牌,我建议您只在标题中设置令牌。

可能的重复项您可以尝试上述解决方案,看看它是否有效吗?这是什么。selectedFiles[]?我将从变量中删除
[]
括号,因为它不是名称的一部分,它将引用一个数组索引,而您不需要这样做access@randy很抱歉,输入错误,我是这样发送的。selectedFields[0]我尝试了第二个链接,它在此行的“setingsdto.Logo.IndexOf”(“,”)+1”处抛出错误。
 return this.httpClient.fetch('http://api.dmsapp.tk/'+url,
            {
                method: method,
                body : json(myPostData),
                headers: {
                'Content-Type': 'application/x-www-form-urlencoded',
                'authorization': this.authorization}})
            .then(response => response.json());