[prev in list] [next in list] [prev in thread] [next in thread]
List: php-general
Subject: [PHP] =?gb18030?B?u9i4tKO6W1BIUF0gUmU6IHdoeSBjYW4ndCB1cGxv?= =?gb18030?B?YWQgZmlsZSBpbnRvIGZ0cCB0YXJ
From: "=?gb18030?B?y66+ssH3ye4=?=" <1248283536 () qq ! com>
Date: 2015-08-31 14:15:50
Message-ID: tencent_4F8A23F944C6354F7A6CBCA6 () qq ! com
[Download RAW message or body]
[Attachment #2 (text/plain)]
i sovle it!!
'ftp://'.$usr .':'.$pwd.'@'.$host.$ftp_path .'/'. $dest
------------------ ÔʼÓʼþ ------------------
·¢¼þÈË: "Christoph Becker";<cmbecker69@gmx.de>;
·¢ËÍʱ¼ä: 2015Äê8Ô 31ÈÕ(ÐÇÆÚÒ») ÍíÉÏ9:23
ÊÕ¼þÈË: "Ë®¾²Á÷Éî"<1248283536@qq.com>; "php-general"<php-general@lists.php.net>;
Ö÷Ìâ: [PHP] Re: why can't upload file into ftp target directory with curl?
Ë®¾²Á÷Éî wrote:
> code1:
>
> <?php
> set_time_limit(0);
> $host = 'xxxx';
> $usr = 'yyyy';
> $pwd = 'zzzz';
> $src = 'd:/upload.sql';
> $ftp_path = '/public_html/';
> $des = 'upload_ftp_put.sql';
> $conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");
> ftp_login($conn_id, $usr, $pwd) or die("Cannot login");
> $upload = ftp_put($conn_id, $ftp_path.$des, $src, FTP_ASCII);
> print($upload);
> ?>
>
> The file `d:/upload.sql` in my local pc can be uploaded into \
> `my_ftp_ip/public_html/upload_ftp_put.sql` with code1. Now i rewite it with \
> curl into code2.
> code2:
>
> <?php
> set_time_limit(0);
> $ch = curl_init();
> $host = 'xxxx';
> $usr = 'yyyy';
> $pwd = 'zzzz';
> $src = 'd:/upload.sql';
> $ftp_path = '/public_html';
> $dest = 'upload_curl.sql';
> $fp = fopen($src, 'r');
> curl_setopt($ch, CURLOPT_URL, 'ftp://user:pwd@host/'.$ftp_path .'/'. $dest);
You'll want to interpolate the values of the variables:
"ftp://$usr:$pwd@$host/'.$ftp_path .'/'. $dest
> curl_setopt($ch, CURLOPT_UPLOAD, 1);
> curl_setopt($ch, CURLOPT_INFILE, $fp);
> curl_setopt($ch, CURLOPT_INFILESIZE, filesize($src));
> curl_exec ($ch);
> $error_no = curl_errno($ch);
> print($error_no);
> curl_close ($ch);
> ?>
>
> The erroor info output is 6 .Why can't upload my local file into the ftp with \
> curl?How to fix it?
--
Christoph M. Becker
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic