added function to extract filename from an entity with error correction in
[squirrelmail.git] / class / mime.class.php
index 8d1def3d81cb4a7afa55a7ceda5150600840f5bc..ebd75bd18efd1c22f6fb95cf9e1484437b110c2b 100644 (file)
@@ -667,6 +667,25 @@ class message
         $this->entities[] = $msg;
     }
 
+    function getFilename()
+    {
+       $filename = '';
+       if (is_object($this->header->disposition))
+       {
+           $filename = $this->header->disposition->getproperty('filename');
+           if (!$filename)
+           {
+               $filename = $this->header->disposition->getproperty('name');
+           }
+       }
+       if (!$filename)
+       {
+           $filename = 'untitled-'.$this->entity_id;
+       }
+       return $filename;
+    }
+
+
     function addRFC822Header($read)
     {
        $header = new rfc822_header();