Agradezco que me den sus opiniones.
Código PHP:
Ver original
namespace modelo\lib; use modelo\CUtil; use modelo\data\ADto; use modelo\Lang; class Files extends ADto { private $_file; private $type; private $size; private $folder; private $name; private $temp; private $extensions; private $formats; public function __construct() { 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', // audio/video 'mp3' => 'audio/mpeg', 'mp3' => 'audio/mp3', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'ppt' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',); parent::__construct(); } public function addUpload($_file) { $this->name = $_file["name"]; $this->size = $_file["size"]; $this->type = $_file["type"]; $this->temp = $_file["tmp_name"]; foreach($this->formats as $key => $f) { if($f==$this->type) { $this->extensions = $key; break; } } if(CUtil::getVacio($this->extensions)) { Messages::addError(NULL,'La extensión que desea ingresar no es soportada'); return FALSE; } return TRUE; } public function getHeaderWrite() { header('Content-Disposition: attachment; filename=' . $this->folder.$this->getNameShort().'.'.$this->extensions); echo $this->getContent(); exit; } protected function getNameShort() { } public function getWriteFile() { } protected function getHeader() { echo $this->getContent(); } public function getContent() { return $this->_file; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $_file * @param field_type */ public final function getFile() { return $this->_file; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $type * @param field_type */ return $this->type; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $size * @param field_type */ public final function getSize() { return $this->size; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $folder * @param field_type */ public final function getFolder() { return $this->folder; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $name * @param field_type */ public final function getName() { return $this->name; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $formats * @param multitype:string */ public final function getFormats() { return $this->formats; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $_file * @param field_type */ public final function setFile($_file) { $this->_file = $_file; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $type * @param field_type */ $this->type = $type; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $size * @param field_type */ public final function setSize($size) { $this->size = $size; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $folder * @param field_type */ public final function setFolder($folder) { $this->folder = $folder; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $name * @param field_type */ public final function setName($name) { $this->name = $name; } /** * @tutorial Metodo Descripcion: * @version 1.0 * @author Miguel Carmona 9/08/2014 * @return the $formats * @param multitype:string */ public final function setFormats($formats) { $this->formats = $formats; } }