How to upload http file via powershell

I want to upload to my host via PowerShell.

But this is not possible for me and I face various obstacles. I came across the internet to find the answer

My powershell code ;

$uri = ""
Invoke-RestMethod -Uri $uri -Method  post  -InFile $txtpath

My php code:

$file_name = $_FILES['UploadedFile']['name'];
$target_path = "uploads/".$file_name;
if(move_uploaded_file($_FILES['UploadedFile']['tmp_name'], $target_path)) {
echo "ok";}
else {
echo "no ok";}
  • I am not sure what the question is here.
    Are you saying, what you show is not working?
    Are you asking how to combine your PoSH samp[le with your PhP sample?
    Are looking to do this with only PoSH and just showing how you would do this in PERL?

    There are scritps on the MS PowerShell Gallery as well as MSDN, TechNet and the O365 blogs, this show how to do this, which you can download and modify to your needs.

    For example, well, this is FTP, but I think you'll get the idea.

    This is to ShoarePoint in O365.

    This is uploading with PoSH using BITS.

    Then there is the Web client upload .Net method.

    So, you do have options, but again, I am not sure of the question here.