How to do a http put using php curl?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
balakrishnach
Forum Newbie
Posts: 1
Joined: Mon Jul 06, 2009 12:30 am

How to do a http put using php curl?

Post 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
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

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

Post 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.
Post Reply