php把文件上传到远程服务器上

CURL

'@'. dirname(__FILE__).'/img/login.gif');
    curl_setopt($curl, CURLOPT_URL, "http://www.demo.com/uploadimg.php");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    $result = curl_exec($curl);
    curl_close($curl);
    echo json_decode($result);
?>


FTP

";
$http_code = curl_getinfo($ch ,CURLINFO_HTTP_CODE);curl_close($ch);
fclose($fp);
?>


你可能感兴趣的:(php把文件上传到远程服务器上)