From 0a77ce59842e34e36ca1bb43afba596e4064a52f Mon Sep 17 00:00:00 2001 From: "Dmitry (dio) Levashov" Date: Thu, 10 Nov 2011 00:31:52 +0400 Subject: [PATCH] ftp driver - upoad files complete --- php/connector.php | 15 ++++++++------- php/elFinderVolumeDriver.class.php | 4 ++-- php/elFinderVolumeFTP.class.php | 18 ++++-------------- 3 files changed, 14 insertions(+), 23 deletions(-) diff --git a/php/connector.php b/php/connector.php index 93701ef13..26ca86a41 100644 --- a/php/connector.php +++ b/php/connector.php @@ -322,13 +322,14 @@ $opts = array( ) ), - // array( - // 'driver' => 'FTP', - // 'host' => 'work.std42.ru', - // 'user' => 'dio', - // 'pass' => '123456', - // 'path' => '/' - // ), + array( + 'driver' => 'FTP', + 'host' => 'work.std42.ru', + 'user' => 'dio', + 'pass' => '123456', + 'path' => '/', + 'tmpPath' => '../files/ftp', + ), // array( // 'driver' => 'FTP', // 'host' => '192.168.1.35', diff --git a/php/elFinderVolumeDriver.class.php b/php/elFinderVolumeDriver.class.php index 8a3e5c202..93b11ac05 100644 --- a/php/elFinderVolumeDriver.class.php +++ b/php/elFinderVolumeDriver.class.php @@ -1364,7 +1364,7 @@ abstract class elFinderVolumeDriver { $w = $s[0]; $h = $s[1]; } - + // $this->clearcache(); if (($path = $this->_save($fp, $dstpath, $name, $mime, $w, $h)) == false) { return false; } @@ -1373,7 +1373,7 @@ abstract class elFinderVolumeDriver { if (isset($removed)) { $this->removed[] = $removed; } - + return $this->stat($path); } diff --git a/php/elFinderVolumeFTP.class.php b/php/elFinderVolumeFTP.class.php index ad73cc453..1f3fc4240 100644 --- a/php/elFinderVolumeFTP.class.php +++ b/php/elFinderVolumeFTP.class.php @@ -831,20 +831,10 @@ class elFinderVolumeFTP extends elFinderVolumeDriver { * @author Dmitry (dio) Levashov **/ protected function _save($fp, $dir, $name, $mime, $w, $h) { - die('Not yet implemented. (_save)'); - $path = $dir.DIRECTORY_SEPARATOR.$name; - - if (!($target = @fopen($path, 'wb'))) { - return false; - } - - while (!feof($fp)) { - fwrite($target, fread($fp, 8192)); - } - fclose($target); - @chmod($path, $this->options['fileMode']); - clearstatcache(); - return $path; + $path = $dir.'/'.$name; + return ftp_fput($this->connect, $path, $fp, strpos($this->mimetype($path), 'text/') === 0 ? FTP_ASCII : FTP_BINARY) + ? $path + : false; } /**