diff --git a/modules/attachments/view_attachment.php b/modules/attachments/view_attachment.php
index 43721ae3c05c39b8bab2415d097e21228d1481fc..b1b690ced3c7e45d7c68ec98b1816ee6d0364952 100755
--- a/modules/attachments/view_attachment.php
+++ b/modules/attachments/view_attachment.php
@@ -155,6 +155,13 @@ if (! empty($_SESSION['error'])) {
             $file      = $docserver . $path . $filename;
             $file      = str_replace("#", DIRECTORY_SEPARATOR, $file);
 
+            if (!copy($file, $_SESSION['config']['tmppath'] . DIRECTORY_SEPARATOR  . $filename)) {
+                echo 'error';
+                exit();
+            } else {
+                $file = $_SESSION['config']['tmppath'] . DIRECTORY_SEPARATOR  . $filename;
+            }
+
             if (strtoupper($format) == "MAARCH") {
                 if (file_exists($file)) {
                     $myfile = fopen($file, "r");