Q:

How do I cURL a file across to a CakePHP controller action?

I'm trying to send a file to a CakePHP controller using cURL to be saved.  Something like:
$file_path = "/full/path/to/file.wav";
$data = array(
    'contents'  => '@'.$file_path
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/cakeapp/uploads/putItem');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
curl_close($ch);

Unfortunately I don't seem to be able to pick up $data on the other side, not in $this->data or in any other way I can think of.  What am I doing wrong here?  Thanks!

A:

Annoyingly (but perhaps unsurprisingly) it doesn't seem to be a problem in the code above, but in pointing at a page on localhost; I moved the cake app to another location and lo and behold, $this->params['form'] was present and correct.  There could still be a better answer to this question if anyone knows what might be causing cURL to fail in such circumstances...

