Code

updated tempalte
[gosa.git] / plugins / admin / systems / class_glpiAttachmentPool.inc
index bddbe307344d16f6f2e706c8beb1d9b7794146f9..25c39880cf02135af620abad071c9e72134c6f3c 100644 (file)
@@ -113,6 +113,7 @@ class glpiAttachmentPool extends plugin
 
       }else{
         $this->parent->handle->deleteAttachment($this->delAttach);
+        @unlink("/etc/gosa/glpi/".$this->filename);
         $attach     = $this->parent->handle->getAttachments();
       }
     }
@@ -133,16 +134,20 @@ class glpiAttachmentPool extends plugin
               print_red(_("Missing directory '/etc/gosa/glpi/' to store glpi uploads."));
             }else{
               $filen = "/etc/gosa/glpi/".$FILE['name'];
-              $fh = fopen($filen,"w");
-              if(!$fh){
-                print_red(sprintf(_("Can't create file '%s'."),$filen));
+              if(file_exists($filen)){
+                print_red(_("There is already a file with the same name uploaded."));
               }else{
-                $str = file_get_contents($FILE['tmp_name']);
-                fwrite($fh,$str,strlen($str));
-                fclose($fh);
-                $this->mime     = $FILE['type'];   
-                $this->filename = $FILE['name'];   
-              }
+                $fh = fopen($filen,"w");
+                if(!$fh){
+                  print_red(sprintf(_("Can't create file '%s'."),$filen));
+                }else{
+                  $str = file_get_contents($FILE['tmp_name']);
+                  fwrite($fh,$str,strlen($str));
+                  fclose($fh);
+                  $this->mime     = $FILE['type'];   
+                  $this->filename = $FILE['name'];   
+                }
+              } // File already exists
             }
           } // Check if any error occured
         } // check if valid filename was uploaded