I'm having a problem and I can not fix it, I have a PHP script that submits a form using cURL.
Initially I used the format array(key => value)
to submit the POST data.
However, I had a problem:
When @ is at the beginning of the field's value, cURL assumes that I'm uploading a file.
To correct this problem I have changed the format that I am putting POST to a string with% GET% format.
However when the value has # (anywhere) it works as a delimiter (equal in links)
In this case the param=@valor
will be lost.
param=va#lor
Well, I could correct this by doing a lor
and when the value has # I would use the if/else
format, but if by chance the value is array
it will fail in both cases.
Can anyone see a light for this problem? Note: Whoever receives the POST is an external server, so I can not send it with URLEncode because it will not be dealt with there.
Sample code that cURL performs:
function exec_curl($ch, $url, $username, $post = null) {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . "/cookies/{$username}.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__). "/cookies/{$username}.txt");
return curl_exec($ch);
}