tags:

views:

50

answers:

2

Hi,

I am trying to upload a file using cURL/php. The same code is working on one hosted server but isn't on another. To upload file using cURL is there specific setting or configuration required for the apache or php?

Nandini

A: 

Yes, make sure that curl extension is enabled where you want to use it. You can check it with:

echo '<pre>';
var_dump(curl_version());
echo '</pre>';

if there was an error, then it means that you do not have this extension enabled. and you will see an error similar to this one:

Fatal error: Call to undefined function curl_version() in testcurl.php on line 2

HOW TO FIX IT:

open you php.ini file and look for this line: extension=php_curl.dll

Sarfraz
A: 
echo '<pre>';
var_dump(curl_version());
echo '</pre>';

gives:

array(9) {
  ["version_number"]=>
  int(463621)
  ["age"]=>
  int(3)
  ["features"]=>
  int(1565)
  ["ssl_version_number"]=>
  int(0)
  ["version"]=>
  string(6) "7.19.5"
  ["host"]=>
  string(24) "x86_64-unknown-linux-gnu"
  ["ssl_version"]=>
  string(14) "OpenSSL/0.9.8b"
  ["libz_version"]=>
  string(5) "1.2.3"
  ["protocols"]=>
  array(8) {
    [0]=>
    string(4) "tftp"
    [1]=>
    string(3) "ftp"
    [2]=>
    string(6) "telnet"
    [3]=>
    string(4) "dict"
    [4]=>
    string(4) "http"
    [5]=>
    string(4) "file"
    [6]=>
    string(5) "https"
    [7]=>
    string(4) "ftps"
  }
}
Nandini
that means it is enabled, make sure that other settings match such as short tags, etc on both servers.
Sarfraz
i am getting an error from the target server which looks like its getting a corrupted file.
Nandini