Skip to content

Instantly share code, notes, and snippets.

@maaddae
Created August 24, 2018 09:14
Show Gist options
  • Save maaddae/9e8564e2292a45f2717127b66472bbc9 to your computer and use it in GitHub Desktop.
Save maaddae/9e8564e2292a45f2717127b66472bbc9 to your computer and use it in GitHub Desktop.
PHP post using the curl
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
ini_set('display_errors',true);
ini_set('display_startup_errors',true);
$target_url = 'http://my-other-domain/phpspreadsheet/receive.php';
$return_url = 'http://127.0.0.1/webfiles/phpspreadsheet/receive.php';
$filename = 'Nalo_contact_sheet.xlsx';
$file_name_with_full_path = realpath('./'.$filename);
$filename_split = explode('.', $filename);
$filename_sufix = $filename_split[1];
$filename_prefix = $filename_split[0];
if ('xlsx' == $filename_sufix) {
$post = array('key' => 'ddf9dcbb413630dd650a9615c921b12d1dbe3e203b8f5d4d08bef5e47cd88979',
'phyle' => new CURLFile($file_name_with_full_path),
'prefix' => $filename_prefix,
'usl' => $return_url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment