@Bacon-Bits answer didn't seem to work for me. My server rejected it with a potentially malformed form-data body :-(
I found this gist, and trimmed it up a bit for my purposes. Here's my end result:
$FilePath = 'c:empemp.txt';
$URL = 'http://your.url.here';
$fileBytes = [System.IO.File]::ReadAllBytes($FilePath);
$fileEnc = [System.Text.Encoding]::GetEncoding('UTF-8').GetString($fileBytes);
$boundary = [System.Guid]::NewGuid().ToString();
$LF = "`r`n";
$bodyLines = (
"--$boundary",
"Content-Disposition: form-data; name=`"file`"; filename=`"temp.txt`"",
"Content-Type: application/octet-stream$LF",
$fileEnc,
"--$boundary--$LF"
) -join $LF
Invoke-RestMethod -Uri $URL -Method Post -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $bodyLines
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…