ANTICHAT

ANTICHAT (https://forum.antichat.io/index.php)
-   PHP (https://forum.antichat.io/forumdisplay.php?f=37)
-   -   как отправить файл на ftp через прокси (https://forum.antichat.io/showthread.php?t=169230)

Student :) 08.01.2010 17:48

как отправить файл на ftp через прокси
 
С прошедшими!
как отправить файл на ftp через прокси с авторизацией?
делаю так
PHP код:

$localfile = "1.html";
$ftpserver = "ftp.narod.ru";
$ftppath   = "";
$ftpuser   = "1";
$ftppasswd   = "22";

$remoteurl = "ftp://${ftpuser}:${ftppasswd}@${ftpserver}${ftppath}/${localfile}";

$ch = curl_init();

$fp = fopen($localfile, "rb");

// we upload a JPEG image
curl_setopt($ch, CURLOPT_PROXY, '10.1.1.1:8080');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:pass');
curl_setopt($ch, CURLOPT_URL, $remoteurl);
curl_setopt($ch, CURLOPT_PUT, 1); 
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_FTPASCII, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);

// set size of the image, which isn't _mandatory_ but helps libcurl to do
// extra error checking on the upload.
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));

curl_exec($ch);

echo 
"<pre>";
print_r(curl_getinfo($ch));
echo 
"\n cURL error number:" .curl_errno($ch);
echo 
"\n cURL error:" . curl_error($ch);  
// check $error here to see if it did fine or not!

curl_close($ch); 



Время: 21:15