'How to rename file using in PHP Using CURL?
I need to rename a file in the server FTPS. I'm using a useful class FTP_Implicit_SSL I have found on the Internet (I need also CURL). I can list directories, upload files, and delete files, however, I cannot rename a file that is in the directory FTP. (The function rename doesn't exist in this library CURL for PHP). I haven't found any function rename here and I am not able to develop a function for renaming.
public function rename_aaron($ruta, $nombre_original, $nombre_nuevo)
{
$sw=0;
if ( ! curl_setopt( $this->curl_handle, CURLOPT_URL, $this->url.$nombre_original ))
throw new Exception ("No se puede establecer el directorio CURL: $this->url");
curl_setopt( $this->curl_handle, CURLOPT_URL, $this->url. $nombre_original);
//curl_setopt( $this->curl_handle, CURLOPT_UPLOAD, 0);
curl_setopt( $this->curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $this->curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->curl_handle, CURLOPT_QUOTE, array('REN '.$punto_partida_ftp.$ruta.$nombre_original.' '.$punto_partida_ftp.$ruta.$nombre_nuevo)); // RENOMBRAMOS
if (curl_exec($this->curl_handle))
{
$sw=1;// cambiado con exito
//return 1;
}
/*else
{
//throw new Exception(sprintf('No se ha podido actualizar el nombre del fichero vía cURL. Error: [%s] - %s', curl_errno( $this->curl_handle ), curl_error( $this->curl_handle )));
return 0;
} */
return $sw;
}
I would like some of help, please. Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|