tibberous Posted August 19, 2007 Share Posted August 19, 2007 How do you post a file to a form with curl? Link to comment https://forums.phpfreaks.com/topic/65714-posting-a-file-to-a-site-with-curl/ Share on other sites More sharing options...
php_tom Posted August 19, 2007 Share Posted August 19, 2007 You mean like this? http://curl.haxx.se/libcurl/php/ Link to comment https://forums.phpfreaks.com/topic/65714-posting-a-file-to-a-site-with-curl/#findComment-328259 Share on other sites More sharing options...
tibberous Posted August 20, 2007 Author Share Posted August 20, 2007 You mean like this? http://curl.haxx.se/libcurl/php/ No. There is nothing on that page that helps me, it is what I would get if I did an "I feeling lucky"... and wasn't. Link to comment https://forums.phpfreaks.com/topic/65714-posting-a-file-to-a-site-with-curl/#findComment-328624 Share on other sites More sharing options...
vijayfreaks Posted August 20, 2007 Share Posted August 20, 2007 Hi.. made one page called "post.php" <?php //parameters for posting data $data = array('var1' => 5,"var2"=>10); // CURL Session initialization $ch = curl_init(); //CURL Option settings curl_setopt($ch, CURLOPT_URL,'http://localhost:9000/post_action.php'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //execution and posting data $res=curl_exec($ch); echo "<pre>"; print_r($res); ?> made another page called "post_action.php" <?php $res= $_POST['var1']+$_POST['var2']; echo $res; ?> now try to run post.php you have summation of 2 vars posted in post.php in response. Regards, Vijay Link to comment https://forums.phpfreaks.com/topic/65714-posting-a-file-to-a-site-with-curl/#findComment-328627 Share on other sites More sharing options...
tibberous Posted August 20, 2007 Author Share Posted August 20, 2007 Thanks. I was looking to be able to send a file though - simulating a file upload. Any idea how I would add a file to the page request? Link to comment https://forums.phpfreaks.com/topic/65714-posting-a-file-to-a-site-with-curl/#findComment-328638 Share on other sites More sharing options...
tibberous Posted August 20, 2007 Author Share Posted August 20, 2007 bump. Link to comment https://forums.phpfreaks.com/topic/65714-posting-a-file-to-a-site-with-curl/#findComment-328696 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.