la base de datos
yo tengo este formulario.php
Código PHP:
Ver original[COLOR="Red"]<?php require_once('Connections/localhost.php'); ?>
<?php[/COLOR][COLOR="Blue"]esta parte la modificas con los datos de tu coneccion[/COLOR]
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ?
intval($theValue) : "NULL"; break;
case "double":
$theValue = ($theValue != "") ?
"'" . doubleval($theValue) . "'" : "NULL"; break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); }
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { [COLOR="Red"]//Guardar imagen
if(is_uploaded_file($_FILES['Imagen']['tmp_name'])) { // verifica haya sido cargado el archivo $ruta= "imagenes/".$_FILES['Imagen']['name'];
}[/COLOR] [COLOR="Blue"]como vez esta parte es la que tienes que modificar con el nombre de tu carpeta y el nombre del formulario[/COLOR]
$insertSQL = sprintf("INSERT INTO formulario (Imagen) VALUES (%s)", GetSQLValueString($ruta, "text"));
$insertGoTo = "ingreso_exisoto.php";
if (isset($_SERVER['QUERY_STRING'])) { $insertGoTo .= (strpos($insertGoTo, '?')) ?
"&" : "?"; $insertGoTo .= $_SERVER['QUERY_STRING'];
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:137px;
top:85px;
width:500px;
height:500px;
z-index:1;
}
-->
</style>
</head>
<body>
<div id="Layer1">
<form id="form1" name="form1" enctype="multipart/form-data" method="POST" action="<?php echo $editFormAction; ?>">
<label for="file"></label>
<p>
<input type="file" name="Imagen" id="Imagen" />
<label></label>
</p>
<label for="Submit"></label>
<input type="submit" name="Submit" value="Enviar" id="Submit" />
<input type="hidden" name="MM_insert" value="form1">
</form>
</div>
</body>
</html>
y este es el ingreso_exitoso.php
Código PHP:
Ver original<?php require_once('Connections/localhost.php'); ?>
<?php
$maxRows_Recordset1 = 5;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
$query_Recordset1 = "SELECT * FROM formulario";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?>
<table border="0" cellpadding="0">
<?php do { ?>
<tr>
<td> </td>
<td><a href="<?php echo $row_Recordset1['Imagen']; ?>"><img src="<?php echo $row_Recordset1['Imagen']; ?>" alt="" width="50" height="50" border="0" lowsrc="imagenes/168483_491704137718_788302718_5827885_3549642_n.jpg"></a></td>
</tr>
</table>
<?php
?>
espero que te sea util yo lo utilizo ien mi sitio que estoy haciendo y funciona de maravillas. cualquier consulta o duda a la orden
este script es con dreamweaver!!