diff --git a/js/commands/paste.js b/js/commands/paste.js index 355770f57..cfcc9dc83 100644 --- a/js/commands/paste.js +++ b/js/commands/paste.js @@ -38,7 +38,8 @@ elFinder.prototype.commands.paste = function() { } this.exec = function(dst) { - var fm = this.fm, + var self = this, + fm = self.fm, dst = dst ? this.files(dst)[0] : fm.cwd(), files = fm.clipboard(), cnt = files.length, @@ -143,7 +144,7 @@ elFinder.prototype.commands.paste = function() { } ; - if (this.disabled() || !files.length) { + if (self.disabled() || !files.length) { return dfrd.resolve(); } diff --git a/php/connector.php b/php/connector.php index 901f63e83..365cede7b 100644 --- a/php/connector.php +++ b/php/connector.php @@ -200,12 +200,13 @@ $opts = array( 'uploadOrder' => 'deny,allow', 'uploadOverwrite' => true, 'uploadMaxSize' => '128m', + // 'copyOverwrite' => false, 'mimeDetect' => 'internal', 'tmbCrop' => false, 'imgLib' => 'imagick', # 'tmbURL' => '.tmb/', 'utf8fix' => false, - 'acceptedName' => '#^[^\.]#', //'/[a-z0-9_\-]+/i', + 'acceptedName' => '/[a-z0-9_\-]+/i', 'attributes' => array( array( 'pattern' => '/\/\..+/', diff --git a/php/elFinderVolumeDriver.class.php b/php/elFinderVolumeDriver.class.php index 1ddeac446..4dc5e740d 100644 --- a/php/elFinderVolumeDriver.class.php +++ b/php/elFinderVolumeDriver.class.php @@ -1216,16 +1216,18 @@ abstract class elFinderVolumeDriver { return $this->setError(elFinder::ERROR_INVALID_NAME); } - if ($copy && !$this->options['copyOverwrite']) { - $name = $this->uniqueName($path, $name, '-', false); - } - $dst = $this->_joinPath($path, $name); if ($this->_fileExists($dst)) { if ($copy) { - if (!$this->options['copyJoin'] && $this->attr($dst, 'write')) { + + if (!$this->options['copyOverwrite']) { + // create unique name to not overwrite old file + $name = $this->uniqueName($path, $name, '-', false); + return $this->_mkdir($path, $name) ? $this->stat($this->_joinPath($path, $name)) : false; + } elseif (!$this->options['copyJoin'] && $this->attr($dst, 'write')) { + // if no join allowed - clean directory foreach ($this->_scandir($dst) as $p) { $this->doRm($p); } @@ -1386,7 +1388,7 @@ abstract class elFinderVolumeDriver { $dst = $this->decode($dst); $_dst = $this->_joinPath($dst, $name); - + if ($this->_fileExists($_dst)) { if (($cmd == 'upload' && !$this->options['uploadOverwrite']) || ($cmd == 'copy' && !$this->options['copyOverwrite'])) { @@ -1704,7 +1706,7 @@ abstract class elFinderVolumeDriver { $i = (int)$m[2]; $name = substr($name, 0, strlen($name)-strlen($m[2])); } else { - $i = 0; + $i = 1; $name .= $suffix; } $max = $i+100000;