Hola me base en un ejemplo que encontre en la red ya pude sacer mis documentos a descargar pero ahora tengo una gran duda como podria para poner comentarios sin usar base de datos esta es la clase
Código php:
Ver original<?php
class download {
var $files = 1;
var $fileTypes = array(); var $mimeTypes = array(); function download($path) {
$this->path = $path;
$this->fileTypes = array('jpeg', 'jpg', 'ico', 'png', 'gif', 'bmp'); $this->ini = dirname(__FILE__)."/mime-type.ini"; }
function getMimetype() {
return (!$this->checkMimetype()) ? 'application/force-download' : $this->mimeTypes[$this->fext];
}
function checkMimetype() {
return isset($this->mimeTypes[$this->fext]) ?
true : false; }
function get($req) {
preg_match("/^[\.\-\s#_a-zA-Z\d]+$/", $req, $file); $this->file = $this->path.$file[0]; $this->fname = $this->parts['basename'];
$this->fext = strtolower($this->parts['extension']); $this->type = $this->getMimetype();
$this->_send();
}
function _send() {
if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-type: ".$this->type.""); header("Content-Disposition: attachment; filename=\"".$this->fname."\""); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".$this->fsize.""); }
function _type($file) {
}
function select($name = 'files', $label = '', $curr = '', $chars = 30) {
if ($handle = opendir($this->path)) { $select = '<form method="post" action="'.$_SERVER['PHP_SELF'].'">'."\n";
$select .= ($label != '') ? '<label for="'.$name.'">'.$label.'</label>'."\n" : '';
$select .= '<select name="'.$name.'" id="'.$name.'">'."\n";
$curr = (isset($_REQUEST[$name])) ?
$_REQUEST[$name] : $curr; $select .= ($curr == "") ? " <option value=\"\" selected>...\n" : "<option value=\"\">...\n";
while (false !== ($file = readdir($handle))) { $array[] = $file;
}
foreach ($array as $val) {
$ext = $this->_type($val);
$select .= ' <option value="'.$val.'">';
$select .= (strlen($val) > $chars) ?
substr($val, 0, $chars).'..'."</option>\n" : $val."</option>\n"; $this->files++;
}
}
$select .= '</select>' ."\n";
$select .= '<input type="submit" name="download" value="Download" />'."\n";
$select .= '</form>'."\n";
}
return ($this->files == 0) ? "No files!" : $select;
}
}
?>