1

I have updated OS X's outdated OpenSSL 0.9.8, and updated cURL to use the new OpenSSL. I have a PHP form where I can upload a picture and I need to run my PHP cURL code on the command line.

I have found many sites that deal with converting command line cURL to PHP, but none that will do the reverse.

...//some other code
$postfields = array(
                'file' =>  '@'   . $filedata
                . ';filename=' . $filename
                . ';type='     . $mimeType
                );

$ch = curl_init($url);
curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_VERBOSE => TRUE,
    CURLOPT_HEADER  => TRUE,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_UPLOAD => TRUE,
    CURLOPT_FOLLOWLOCATION => TRUE,
    CURLOPT_SSL_VERIFYPEER => FALSE,
    CURLOPT_HTTPHEADER => array(
        'Content-Type: '. $mimeType,
        'Session-Id: ' . getSessionId($profileID)
    ),
    CURLOPT_POSTFIELDS => $fullPath
));

// Send the request

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);

..//more code dealing with the response

Can I package up my $ch and drop it in a php_exec?

Is what I want to do even possible?

jww
  • 97,681
  • 90
  • 411
  • 885
user-44651
  • 3,924
  • 6
  • 41
  • 87
  • 2
    I may not be getting the gist of it but can't you just call php /path/to/file.php ? – Taff Apr 08 '16 at 15:04
  • Possible duplicate of [php exec() is not executing the command](http://stackoverflow.com/questions/17914402/php-exec-is-not-executing-the-command). – jww Apr 08 '16 at 15:34

0 Answers0