cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Deleting a file using curl and php

From: Stephen Pynenburg <spynenburg_at_gmail.com>
Date: Sun, 31 Aug 2008 16:55:02 -0400

I'm pretty sure you have to use something like this:
<?PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "ftp://user:pwd@ftp.site.com");
curl_setopt($ch, CURLOPT_QUOTE, array("DELE /path/to/file.ext"));
curl_exec($ch);
?>
Although I've never actually done it myself. Note that you have to use
commands compliant with this RFC: http://www.faqs.org/rfcs/rfc959.html
As opposed to the shell/command line options you're probably used to.

-Stephen

2008/8/31 Adam Richardson <adam_at_envisionic.com>

> Hi, I've searched on google and didn't see anything on how to do this.
>
> I'm aware of code like the following that allows me to update or save a
> file to a server using ftp within curl:
>
>
> <?php
> //
> // A simple PHP/CURL FTP upload to a remote site
> //
>
> $ch = curl_init();
> $localfile = "me-and-my-dog.jpg"
>
> $fp = fopen ($localfile, "r");
>
> // we upload a JPEG image
> curl_setopt($ch, CURLOPT_URL,
> "ftp://mynamw:mypassword@ftp.mysite.com/path/to/destination.jpg");
> curl_setopt($ch, CURLOPT_UPLOAD, 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));
>
> $error = curl_exec ($ch);
>
> // check $error here to see if it did fine or not!
>
> curl_close ($ch);
> ?>
>
> How do I alter this code to delete a file on a remote server?
>
> Thank you for your help,
>
> Adam
>
> _______________________________________________
> 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-08-31