Not able to post the file through curl on amazon ec2 instance -
i have hosted website on amazon ec2 instance. facing problem there i.e. when trying post files/images through curl posts url target url need post image content on there. posting image using below given code :
$target_url = 'http://www.alvinmcbride.com/facereaderpost/api/facereader/postimage'; $post = array('myimage'=>'@'.$frame_existing_path); $curl = curl_init(); curl_setopt($curl, curlopt_url,$target_url); curl_setopt($curl, curlopt_post,1); curl_setopt($curl, curlopt_postfields, $post); curl_setopt($curl, curlopt_returntransfer,1); $result=curl_exec ($curl); curl_close ($curl); $api_emotions_array[$frame_time] = json_decode($result, true);
and in response gives message "invalid image" every image. please suggest if doing wrong. because same code working fine on other servers shared/dedicated servers.
use curl_file_create() function work me on amazon hosting..
$tmpfile = $_files['image']['tmp_name']; $filename = basename($_files['image']['name']); $filetype = $_files['image']['type']; $image_string =curl_file_create($tmpfile,$filetype,$filename);
normally
$org_image_string = '@'.$tmpfile.';filename='.$filename;
work me on local , other server not work on amazon hosted site. hence use curl_file_create , work :)
Comments
Post a Comment