How to put file contents using wget in post variable?

I have a very simple php script:

<?
  $received:file = $_POST['file'];
  // do something with it
?>

I am trying to publish the contents of a local file (unix) using wget.

wget --post-data='operation=upload' --post-file myfile 

it seems to be sent, but not attached to any "field".

How can i do this?

+5
source share
1 answer

Do you really need wget? In fact, after reading the wget man page ... wget cannot do what you want.

you can use curl

curl -F"operation=upload" -F"file=@myfile" http://localhost:9000/index.php

Get file using

<?php
$uploadfile = '/tmp/' . basename($_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);
$content = file_get_contents($uploadfile);
?>
+7
source

All Articles