que tengo una tabla = "foto" con llos campos id,archivo,tipo,peso,titulo.
pero no se por que se me agregan dos campos mas(dos arrays de errores).
aqui el error: No se ha podido realizar la consultaUnknown column 'errores' in 'field list'
Ultima consulta sql:INSERT INTO foto(id,archivo,tipo,peso,titulo,errores,errores_u pload ) VALUES ('','Hydrangeas.jpg','image/jpeg','595284','','Array','Array')
php del formulario:
Código PHP:
Ver original<form action="formulario.php" method="post" enctype="multipart/form-data">
<table>
<!-- <tr>
<td>autor:</td>
<td><input type="text" name="autor" /></td>
</tr>
<tr>
<td>titulo:</td>
<td><input type="text" name="titulo" /></td>
</tr>
<tr>
<td>precio:</td>
<td><input type="text" name="precio" /></td>
</tr>
-->
<tr>
<td><input type="hidden" name="MAX_FILE_SIZE" value="1000000" /></td>
</tr>
<tr>
<td>archivo:</td>
<td><input type="file" name="file_upload" /></td>
</tr>
<tr>
<td>titulo imagen</td>
<td><input type="text" name="titulo" value="" /></td>
</tr>
</table>
<input type="submit" name="submit" value="Ingresar" />
</form>
</td>
</tr>
</table>
codigo php que procesa el insertado.
Código PHP:
Ver original<?php
class Foto extends tabla
{
public $id;
public $archivo;
public $tipo;
public $peso;
public $titulo;
private $nombre_tmp;
private $fotos_dir ="images";
public $errores = array(); public $errores_upload = array( UPLOAD_ERR_OK => "no se ha producido ningún error",
UPLOAD_ERR_INI_SIZE =>"El tamaño de archivo ha excedido el maximo indicando en php.ini",
UPLOAD_ERR_FORM_SIZE => "El tamañode archivo ha excedido el maximo para este formulario",
UPLOAD_ERR_PARTIAL => "El archivo ha sido subido parcialmente",
UPLOAD_ERR_NO_FILE=> "el archivo no existe",
UPLOAD_ERR_NO_TMP_DIR=>"El directorio temporal no existe",
UPLOAD_ERR_CANT_WRITE=> "No se puede escribir en el disco duro",
UPLOAD_ERR_EXTENSION=> "Error en una extensión php");
protected static $nombre_tabla = "foto";
protected static
$campos_tabla = array("archivo", "tipo","peso","titulo");
public function adjuntar_foto($info)
{
{
array_push($errores,"no se a pasado ninguna informacion de archivo."); return false;
}
elseif ($info["error"] != 0)
{
array_push($errores,$errores_upload[$info["error"]]); return false;
}
else
{
$this->archivo = basename($info["name"]); $this->peso = $info["size"];
$this->tipo = $info["type"];
$this->nombre_tmp = $info["tmp_name"];
return true;
}
}
public function guardar()
{
{
if(!empty($this->errores)) {
return false;
}
if(strlen($this->titulo) > 255) {
$this->errores[] = "El titulo posee más de 255 caracteres";
return false;
}
$nueva_ruta = RAIZ_DIR.SD."public".SD.$this->fotos_dir.SD.$this->archivo;
if(empty($this->nombre_tmp)) {
$this->errores[] = "No se tienen los datos suficientes";
return false;
}
{
$this->errores[] = "No se puede utilizar ese nombre de archivo";
return false;
}
{
if($this->crear())
{
return true;
}
else
{
return false;
$this->errores[ ] = "No se ha podido crear el registro en la base de datos";
}
}
else
{
$this->errores[] = "No se ha podido mover el archivo subido a una ubicación segura.";
return false;
}
}
else
{
$this->actualizar();
}
}
}
?>