altocompta/include/class_filetosend.php
Dany De Bontridder 9c9003644a Task #946 : envoi de fichier par email
Task #946 - Envoi de fichier par email
2013-12-17 17:28:09 +00:00

56 lines
1.3 KiB
PHP

<?php
/**
* @brief file to add to a message
*
* @see Sendmail
* @author dany
*/
class FileToSend
{
var $filename;
var $type;
var $path;
var $full_name;
function __construct($p_filename,$p_type="")
{
$this->full_name=$p_filename;
if (strpos($p_filename,'/') != false)
{
$this->path=dirname($p_filename);
}
$this->filename=basename ($p_filename);
if ( $p_type=="")
{
$this->guess_type();
}
}
function guess_type()
{
$ext_pos= strrpos($this->filename,'.');
if ( $ext_pos == false ) {
$this->type="application/octect";
return;
}
$ext= substr($this->filename, $ext_pos+1, 3);
switch ($ext)
{
case 'odt':
$this->type='application/vnd.oasis.opendocument.text';
break;
case 'ods':
$this->type='application/vnd.oasis.opendocument.spreadsheet';
break;
case 'pdf':
$this->type="application/pdf";
break;
case 'zip':
$this->type="application/zip";
break;
default:
$this->type="application/octect";
}
}
}