-  if (!copy(join('/', $form->{tmpdir}, $form->{tmpfile}), join('/', $form->{cwd}, $webdav_folder, $myfilename))) {
-    my $from = join('/', $form->{tmpdir}, $form->{tmpfile});
-    my $to   = join('/', $form->{cwd},    $webdav_folder);
-    $::lxdebug->message(LXDebug::WARN(), "Copy file from $from to $to failed");
-    $::form->error($::locale->text("Copy file from #1 to #2 failed", $from, $to));
+  if (!File::Copy::copy($current_file, $new_file)) {
+    $::lxdebug->message(LXDebug::WARN(), "Copy file from $current_file to $new_file failed: $ERRNO");
+    $::form->error($::locale->text("Copy file from #1 to #2 failed: #3", $current_file, $new_file, $ERRNO));