modified to use CURLFile object as suggested in PHP 5.5 and above