Using FTP from PHP CURL

Posted by Christian Sciberras on Stack Overflow See other posts from Stack Overflow or by Christian Sciberras
Published on 2010-04-19T12:57:59Z Indexed on 2010/04/19 13:03 UTC
Read the original article Hit count: 384

Filed under:
|
|
|

I can't figure out how to use CURL's FTP, specifically, how to issue FTP commands from my PHP code:

<?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'ftp://ftp.microsoft.com/');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($ch,CURLOPT_POSTQUOTE,array('CWD bussys/','LIST')); /* ?!! */

    echo '<hr><pre>'.htmlspecialchars(curl_exec($ch)).'</pre><hr>';
?>

In my example above I want to get a directory listing of bussys, but instead I get a listing of the main (FTP root) directory.

© Stack Overflow or respective owner

Related posts about php

Related posts about ftp