我试图通过invoke-restmethod
通过多部分表单数据发送文件。我在服务器上没有写权限,但类型filename工作得很好我的命令是Invoke-RestMethod -Uri url -Method Post -infile file
如果文件位于网络位置或只读,则可能文件在PowerShell中不可用。此处描述只读问题:https://www.reddit.com/r/PowerShell/comments/pwhsw2/invokerestmethod_method_put_infile_doesnt_work/
基本上是改变权限,因为PowerShell有bug:
Set-ItemProperty -Path <path> -Name IsReadOnly -Value $False
请重试。如果你不能更改权限,你可以切换到PowerShell 7