note 104258 added to function.curl-setopt
| From: | anjith dot garapati at softima dot com | Date: | Sat, 04 Jun 2011 05:31:21 +0000 |
| Subject: | note 104258 added to function.curl-setopt | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180244@lists.php.net to get a copy of this message | ||
Hi,
I am doing ftp using curl until today, cilent want to keep a router in
before server so that all requests to server should go through it. The
router is configured so that eveery ftp request will be redirected to
21 port of the server through team viewer i have installed ftp server
on port 21. But using curl program i previously used i am unable to do
ftp with server.
Below is the code i used before and after router is placed.
Old code:-
<?php
$url="SEVER IP";
$user_pwd ="username:password" ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, $user_pwd);
$putData = tmpfile();
fwrite($putData, $strData);
fseek($putData, 0);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $putData);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($strData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$strContent = curl_exec($ch);
$err = curl_errno($ch);
fclose($putData);
curl_close($ch);
?>
New code i have changed only url to router ip and appened port number and kept few options true
<?php
$url="router_ip:port_number";
$user_pwd ="username:password" ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_USERPWD, $user_pwd);
$putData = tmpfile();
fwrite($putData, $strData);
fseek($putData, 0);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $putData);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($strData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$strContent = curl_exec($ch);
$err = curl_errno($ch);
fclose($putData);
curl_close($ch);
?>
Did i need to do anything more or it is problem with router and ftp
server installed on server
----
Server IP: 69.147.83.197
Probable Submitter: 123.176.39.242
----
Manual Page -- http://www.php.net/manual/en/function.curl-setopt.php
Edit -- https://master.php.net/note/edit/104258
Del: integrated -- https://master.php.net/note/delete/104258/integrated
Del: useless -- https://master.php.net/note/delete/104258/useless
Del: bad code -- https://master.php.net/note/delete/104258/bad+code
Del: spam -- https://master.php.net/note/delete/104258/spam
Del: non-english -- https://master.php.net/note/delete/104258/non-english
Del: in docs -- https://master.php.net/note/delete/104258/in+docs
Del: other reasons-- https://master.php.net/note/delete/104258
Reject -- https://master.php.net/note/reject/104258
Search -- https://master.php.net/manage/user-notes.php