curl-and-php
Re: delete file from ftp with quote
Date: Mon, 28 Jul 2008 20:04:29 -0400
Hey,
I don't think the QUOTE options are skipped, but I can't seem to find any
that work. With the code:
<?PHP
$command = array('ls /');
$ftp_url = "ftp://ftp.freehostia.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_USERPWD, "[user]:[password]");
curl_setopt($ch, CURLOPT_FTPLISTONLY, 0);
curl_setopt($ch, CURLOPT_URL, $ftp_url);
curl_setopt($ch, CURLOPT_POSTQUOTE, $command);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
$res = curl_exec ($ch);
echo curl_error($ch);
curl_close ($ch);
}
?>
I get a directory listing returned, as well as the following error:
QUOT string not accepted: ls /
As per Daniel's advice, I did poke around in the libcurl docs, but the only
thing I could find relating to it was for the C binding -
http://curl.haxx.se/lxr/source/docs/examples/ftpupload.c
If all else fails, I guess you could just use something like
passthru('curl -Q "DELE filename" ftp://user:pass@host/path')
-Stephen
On Mon, Jul 28, 2008 at 4:07 AM, Gaetano Favoino
<gaetano.favoino_at_gmail.com>wrote:
> Hi Daniel,
> I've already tried with various commands but quote commands passed by
> array are skipped...
> Can anyone provide a simple working example to delete a file from ftp
> server with curl?
>
> Best regards,
>
> On Fri, Jul 25, 2008 at 10:56 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> > On Fri, 25 Jul 2008, Gaetano Favoino wrote:
> >
> >> $comandi_array[] = "\"-dele FNVAC20080716140014.CHK\"";
> >
> > "-dele" is not a command that you can send to the server and assume it'll
> > understand. The system with '-' prefix is what the command line tool
> uses,
> > libcurl itself has different setopt options for actions to be done before
> or
> > after the transfer. See the libcurl docs for details.
> >
> > --
> >
> > / daniel.haxx.se
> > _______________________________________________
> > http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> >
>
>
>
> --
> Gaetano Favoino
> gaetano.favoino_at_gmail.com
> PGP-FP E97A 062D 359A 5B09 FFE9 4842 EDEF EEF6 4AA3 CAEC
> :wq
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-07-29