diff --git a/lib/file-control.php b/lib/file-control.php
index bec474d..945ef96 100644
--- a/lib/file-control.php
+++ b/lib/file-control.php
@@ -55,7 +55,7 @@ if ($_GET['action']=="newFolder") {
// If we're due to paste a new file...
if ($_GET['action']=="paste") {
$source = $file;
- $dest = $docRoot.strClean(str_replace("|","/",$_GET['location']))."/".basename($source);
+ $dest = str_replace("//","/",$docRoot.strClean(str_replace("|","/",$_GET['location']))."/".basename($source));
if (!$demoMode && is_writable(dirname($dest))) {
if (is_dir($source)) {
if (!is_dir($dest)) {
@@ -72,10 +72,20 @@ if ($_GET['action']=="paste") {
}
}
} else {
- copy($source, $dest);
+ if (!file_exists($dest)) {
+ copy($source, $dest);
+ } else {
+ for ($i=2; $i<1000000000; $i++) {
+ if (!file_exists($dest." (".$i.")")) {
+ $dest = $dest." (".$i.")";
+ copy($source, $dest);
+ $i=1000000000;
+ }
+ }
+ }
}
// Reload file manager
- echo '';
+ echo '';
} else {
echo "";
}