25/02/2013, 07:40
|
| | Fecha de Ingreso: febrero-2013
Mensajes: 2
Antigüedad: 12 años Puntos: 0 | |
Respuesta: Extraer variable de una función y utilizarla en otra <?php
class clasearchivo
{
var $archivar;
private $conexion=0;
function __construct()
{
$this->conexion=mysql_connect('localhost','root','12345' ) or die ('Error al consultar');
mysql_select_db('actas', $this->conexion) or die ('Error en la base de datps');
}
function __destruct()
{
mysql_close($this->conexion);
}
public function cargar($archivar)
{
global $tipos,$maximo,$archivo,$tamanio,$tipo,$nombre_arc hivo,$fp,$contenido,$query,$si_subio,$id_archivo,$ archivar ;
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Subir Archivo Word o Excel.... A MySQL</title>
<link href="../css/style/style12.css" rel="stylesheet" type="text/css" />
</head>
<body >
<center>
<div id="container">
<div id="header"><div id="header_left"></div>
<div id="header_main">Subir Archivo Word o Excel....</div><div id="header_right"></div></div>
<div id="content">
<form action="" method="post" enctype="multipart/form-data">
<p id="f1_upload_process">Procesando...<br/><img src="http://www.forosdelweb.com/f18/css/style/loader.gif" /><br/></p>
<p id="f1_upload_form" align="center"><br/>
<label>File:
<input name="archivo" type="file" id="archivo" size="30" />
</label>
<label>
<input type="submit" name="submitBtn" class="sbtn" value="Subir" />
</label>
</p>
</form>
</div>
</div>
</center>
</body>
<?php
$si_subio=false;
$archivar="";
$ini=0;
if (isset($_FILES['archivo']) )
{
// application/msword ======> Word 2003,
// application/vnd.openxmlformats-officedocument.wordprocessingml.document ===========> Word 2007 and 2010
// application/vnd.ms-excel =======> Excel 2003
// application/vnd.openxmlformats-officedocument.spreadsheetml.sheet =========> Excel 2007 and 2010
// Cargar en un arreglo los formatos de archivos permitidos
$tipos = array("application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","applica tion/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
$maximo = 100204000;
if (in_array($_FILES['archivo']['type'],$tipos))
{
if($_FILES['archivo']['size'] <= $maximo)
{
$archivo = $_FILES["archivo"]["tmp_name"];
$tamanio=array();
$tamanio = $_FILES["archivo"]["size"];
$tipo = $_FILES["archivo"]["type"];
$nombre_archivo = $_FILES["archivo"]["name"];
extract($_REQUEST);
if ( $archivo != "none" )
{
$fp = fopen($archivo, "rb");
$contenido = fread($fp, $tamanio);
$contenido = addslashes($contenido);
fclose($fp);
$query = "INSERT INTO `archivos` (archivo,nombre,tipo) VALUES
('$contenido','$nombre_archivo','$tipo')";
//$archivos="INSERT INTO `tareas` (id_archivo) VALUES ('$id_archivo')";
if (mysql_query($query))
{
$si_subio=true;
$id_archivo= mysql_insert_id();
$archivar= $id_archivo;
echo' "'.$archivar.'"';
echo "
<script>
var decide = confirm('Desea borrar el registro?');
if(!decide) window.location='elemento.php?opt=l';
else window.location='archivo.php?opt=i&id=".$_GET['id']."';
</script>";
}
}
}
}
}
}
public function formularioregistrar ()
{
echo'essss "'.$archivar.'"';
echo'<form action="" method="POST">
<div id="formulario" style="width:400px;height:370px;overflow:auto;">
<table>
<h2>Informacion de la tarea</h2>
<tr><td>Nombre </td><td><input type="text" id="nombre" name="nombre" value="'.$res[1].'" required/><br /></td></tr>
<tr><td>Estado </td><td><input type="text" id="estado" name="estado" value="Pendiente" readonly /><br /></td></tr>
<tr><td>Fecha de creacion </td><td><input type="date" id="fecha_creacion" name="fecha_creacion" value="'.$res[3].'" required/><br/></td></tr>
<tr><td>Fecha de ejecución </td><td><input type="date" id="fecha_ejecucion" name="fecha_ejecucion" value="'.$res[4].'" required/><br/></td></tr>
<br><br><tr><td><input type="submit" value="Registrar" /></td></tr>
</table>
</div>
</form>';
}
public function registrar ()
{
$nombre = $_POST['nombre'];
$estado = $_POST['estado'];
$fecha_creacion = $_POST['fecha_creacion'];
$fecha_ejecucion= $_POST['fecha_ejecucion'];
$sql='INSERT INTO tareas VALUES ("'.NULL.'","'.$nombre.'","'.$estado.'","'.$fecha_ creacion.'","'.$fecha_ejecucion.'")';
$busqueda = mysql_query($sql,$this->conexion) or die('Error en la consulta');
echo'el valor del nomre es "'.$nombre.'"';
//echo '<script>window.location="archivo.php?opt=c";</script>';
}
} |