Good,
Here is another solution: Downloading FIL from the leisure client to the leisure server
But none of these solutions worked for me.
However, this is what worked; actually worked.
Firstly, I was not sure if my file reached the method, so I changed the response line to:
function enter_post() { $this->response($_FILES); }
Please note that this is a great way to test your REST methods.
You can also output:
$ this-> answer ($ _ SERVER);
and
$ this-> answer ($ _ POST);
and etc.
I got the following JSON output:
{"file": {"name": "camel.jpg", "type": "application / octet stream", "tmp_name": "/ TMP / phpVy8ple", "error": 0, "size": 102838 }}
So, I knew that my file was there.
Then I changed the method to find and move the file. I used file sharing script to get the file from its temporary location and move it to a new location:
$uploaddir = '/home/me/public_html/uploads/'; $uploadfile = $uploaddir . basename($_FILES['file']['name']); if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { $data['status'] = 'uploaded'; } else { $data['status'] = 'failed'; }
ssaltman
source share