1

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

$uri = "http://myurl.com/uploader.php"
$txtpath="C:\Users\masod\Desktop\tt.txt"
Invoke-RestMethod -Uri $uri -Method  post  -InFile $txtpath

My php code:

<?php
$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";}
?>
7
  • this is my php code <?php $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";} ?> Commented Oct 17, 2017 at 15:43
  • Have you tried stackoverflow.com/questions/38164723/… and stackoverflow.com/questions/24672760/… ? Commented Oct 17, 2017 at 15:50
  • excuse me It did not help me. Could my code be damned? Commented Oct 17, 2017 at 17:26
  • It could be, however, I am not experienced in using powershell for uploading files. So I might be wrong. Commented Oct 18, 2017 at 5:46
  • It is ridiculous There is no one to answer my question Commented Oct 18, 2017 at 8:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.