You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用PowerShell向uploadserver上传文件?

解决PowerShell上传文件到uploadserver的400错误

错误原因是uploadserver要求上传请求采用multipart/form-data格式,且文件对应的表单字段必须命名为files,你之前的命令直接将文件内容作为请求体发送,不符合服务器的接收规则。

正确的上传命令

使用Invoke-WebRequest(或Invoke-RestMethod)的-Form参数构造符合要求的表单请求:

单文件上传

Invoke-WebRequest -Uri http://192.168.0.164:8000/upload -Method Post -Form @{
    files = Get-Item "file.txt"
}

多文件上传

如果需要同时上传多个文件,可将文件路径放入数组:

Invoke-WebRequest -Uri http://192.168.0.164:8000/upload -Method Post -Form @{
    files = @(Get-Item "file1.txt", "file2.jpg", "document.pdf")
}

说明

-Form参数会自动处理multipart/form-data的编码,将指定文件以files字段名提交,完全匹配uploadserver的接收要求。

内容的提问来源于stack exchange,提问作者MegaMagnum

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 18:55:23