Page 1 of 1

How to do a http put using php curl?

Posted: Mon Jul 06, 2009 1:06 am
by balakrishnach
Hi all,
Can any one help me regarding how to do a put an file in php using curl?
i posted a file using the following code:
<?php
$data="<root>
<name>test</name>
<Description>foo</Description>
<Created_User>abc</Created_User>
</root>";
$ch = curl_init();
$url = "some url";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
curl_close($ch);
?>
it get posted. Now i want to modify the <name> to 'xyz' from 'test'. How can i do that on that url?
Thanks & Regards
Balakrishna

Re: How to do a http put using php curl?

Posted: Mon Jul 06, 2009 1:26 am
by omniuni
You will need to pass a variable. Instead of using the entire string, break it where it says "test" and instead put in a variable like $data1.