I have looked through other answers but I believe that my problem may be different. I'm not a cURL whiz and I'm hoping that someone can advise me where I should be directing my efforts.
Local PHP script transmits $_POST array containing text values and a file. Data is received by a PHP script on server. No browser in the equation. I picked up the code off the internet.
Works perfectly on local development HTTP server (Cherokee). Fails on remote live HTTP server (Apache).
Sending code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
post_array=array("my_file"=>"@".$File,"upload"=>"Upload","var1"=>P1,"var2"=>P2,"var3"=>P3);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
if(!curl_errno($ch))
{
$info = curl_getinfo($ch);
echo 'Took ' . $info['total_time'] . ' seconds to send a request to ' . $info['url'];
}
Sending script displays $_POST content as:
Array
(
[my_file] => @<path to file>
[upload] => Upload
[var1] => P1
[var2] => P2
[var3] => P3
)
On remote server, $_POST array is received by script as:
Array
(
[upload] => Upload
)
I'm using CURLOPT_VERBOSE and I get the following screen output:
* About to connect() to <domain name> port 80 (#0)
* Trying 82.71.205.4... * connected
> POST <receiving file> HTTP/1.1
User-Agent: Mozilla/4.0 (compatible;)
Host: <domain name>
Accept: */*
Content-Length: 22091
Expect: 100-continue
Content-Type: multipart/form-data; boundary=----------------------------734a2c311f30
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< Date: Thu, 21 Nov 2013 14:09:13 GMT
< Server: Apache
< X-Powered-By: PHP/5.3.17
< Content-Length: 199
< Content-Type: text/html
<
* Connection #0 to host <domain name> left intact
Took 0.718261 seconds to send a request to <receiving file>
So, I know the following:
1/ Script works perfectly on dev server, but on live server...
2/ curl_errno says no errors.
3/ CURLOPT_VERBOSE reports expected array size (22091).
4/ Receiving file receives data, but not $_POST array content.
5/ No entries in server error log.
Can anyone tell me where I should be investigating please?