How to do -F in PHP cURL? -



How to do -F in PHP cURL? -

i have next curl console commands

curl -i -x post -u username:password https://foo.com/api/metadata/ -f key="url" -f value="http://foo.com" curl -i -x post -u username:password https://foo.com/api/queries/ -f image=@/tmp/image.jpg

how pass -f parameter values in php curl

add file in post fields , utilize curl next code:

$post = array('extra_info' => '123456','file_contents'=>'@'.$file_name_with_full_path); $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;

note: utilize realpath() file path.

more details

php curl

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -