From: hickert Date: Wed, 25 Jan 2006 09:03:08 +0000 (+0000) Subject: Added check to avoid multiple uploads of the same file X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c54c0b4c14c7f286f62efbb41c810f1799ebaae4;p=gosa.git Added check to avoid multiple uploads of the same file git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2572 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/admin/systems/class_glpiAttachmentPool.inc b/plugins/admin/systems/class_glpiAttachmentPool.inc index bddbe3073..896ed980b 100644 --- a/plugins/admin/systems/class_glpiAttachmentPool.inc +++ b/plugins/admin/systems/class_glpiAttachmentPool.inc @@ -133,16 +133,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