Browse Source

added function to extract filename from an entity with error correction in
case the disposition isn't defined

stekkel 23 years ago
parent
commit
6f4e609385
1 changed files with 19 additions and 0 deletions
  1. 19 0
      class/mime.class.php

+ 19 - 0
class/mime.class.php

@@ -667,6 +667,25 @@ class message
         $this->entities[] = $msg;
         $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)
     function addRFC822Header($read)
     {
     {
 	$header = new rfc822_header();
 	$header = new rfc822_header();