InicioInfoSubir Imagenes facil, guardar el nombre y ruta en Base datos

Subir Imagenes facil, guardar el nombre y ruta en Base datos

Info11/7/2011

Alguien me pidió algo interesante para aprender,
Este fue un problema real, al cual me enfrente, y muchos me dijeron que no se podía hacer, no se como lo hice pero lo logre.

Muchos han querido crear un formulario para subir imágenes y guardar la información de la imagen en una base datos para luego usarla, por ejemplo yo, para mostrar clasificados.
Muchos me dijeron que usara Ajax, etc, y al final termine sin hacer nada, pues tantas vinculaciones botaba al usuario de la pagina, ahora bien el modelo es muy básico, y hasta feo, pero funciona y el concepto esta, lo puedes mejorar y usar. Adáptalo a tus necesidades.
Recuerda invocar las bases de datos, y el login del usuario.
Esto fue creado en Dream Veawer Cs3

Chao.

<?php require_once('../base de datos usuarios.php'); ?><?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != ""){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true"){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

$logoutGoTo = "login.php";
if ($logoutGoTo) {
header("Location: $logoutGoTo";
exit;
}
}
?>
<?php require_once('../Tu Conexion a la base de datos'); ?>
<?php require_once('../Tu Conexion a la base de datos'); ?><?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "" && true) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "error.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?") $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString") {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string" ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

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;
}
}

mysql_select_db($database_XXXXXXX, $inmuebles);
$query_Recordset3 = "SELECT * FROM conteo";
$Recordset3 = mysql_query($query_Recordset3, $inmuebles) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);

mysql_select_db($database_XXXXXXX, $usuarios);
$query_Recordset1 = "SELECT * FROM usuarios";
$Recordset1 = mysql_query($query_Recordset1, $usuarios) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

mysql_select_db($database_XXXXXXX, $empresas);
$query_Recordset2 = "SELECT * FROM empresas";
$Recordset2 = mysql_query($query_Recordset2, $empresas) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

mysql_select_db($database_XXXXXXX, $inmuebles);
$query_Recordset4 = "SELECT * FROM historico";
$Recordset4 = mysql_query($query_Recordset4, $inmuebles) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 = mysql_num_rows($Recordset4);

mysql_select_db($database_XXXXXXX, $usuarios);
if (isset($_SESSION['MM_Username'])) {
$usuario = $_SESSION['MM_Username'];}
$query_Recordset1 = "SELECT * FROM usuarios WHERE usuario = '$usuario'";
$Recordset1 = mysql_query($query_Recordset1, $usuarios) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$inmobiliaria = $row_Recordset2['empresa'];

mysql_select_db($database_XXXXXXX, $empresas);
if (isset($_SESSION['MM_Username'])) {
$usuario = $_SESSION['MM_Username'];}
$query_Recordset2 = "SELECT * FROM empresas WHERE usuario = '$usuario'";
$Recordset2 = mysql_query($query_Recordset2, $empresas) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);

mysql_select_db($database_XXXXXXX, $inmuebles);
$query_Recordset4 = "SELECT * FROM historico where usuario = '$usuario' and inmobiliaria = '$inmobiliaria'";
$Recordset4 = mysql_query($query_Recordset4, $inmuebles) or die(mysql_error());
$row_Recordset4 = mysql_fetch_assoc($Recordset4);
$totalRows_Recordset4 = mysql_num_rows($Recordset4);
$cantidadclasificadosusados = $totalRows_Recordset4;

mysql_select_db($database_XXXXXXX, $inmuebles);
$query_Recordset3 = "SELECT * FROM conteo where usuario = '$usuario' and inmobiliaria = '$inmobiliaria'";
$Recordset3 = mysql_query($query_Recordset3, $inmuebles) or die(mysql_error());
$row_Recordset3 = mysql_fetch_assoc($Recordset3);
$totalRows_Recordset3 = mysql_num_rows($Recordset3);

$clasificadoscomprados = $row_Recordset3['cantidadclasificados'];
$autorizado = $clasificadoscomprados - $cantidadclasificadosusados;




?>
<!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=utf-8" />
<title>Panel de Control</title>
<style type="text/css">
<!--
.Estilo1 {
font-size: 24px;
font-weight: bold;
}
.Estilo2 {
font-size: 14px;
font-weight: bold;
}
.Estilo4 {font-size: 16px; font-weight: bold; }
.Estilo6 {font-size: 18px; font-weight: bold; }
.Estilo7 {font-size: 36px; font-weight: bold; }
.fondo {
background: #b5ddb5; /* Old browsers */
background: -moz-linear-gradient(top, hsla(120,37%,79%,1) 0%, hsla(120,100%,17%,1) 67%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,hsla(120,37%,79%,1)), color-stop(67%,hsla(120,100%,17%,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, hsla(120,37%,79%,1) 0%,hsla(120,100%,17%,1) 67%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, hsla(120,37%,79%,1) 0%,hsla(120,100%,17%,1) 67%); /* Opera11.10+ */
background: -ms-linear-gradient(top, hsla(120,37%,79%,1) 0%,hsla(120,100%,17%,1) 67%); /* IE10+ */
filter: progidXImageTransform.Microsoft.gradient( startColorstr='#b5ddb5', endColorstr='#005600',GradientType=0 ); /* IE6-9 */
background: linear-gradient(top, hsla(120,37%,79%,1) 0%,hsla(120,100%,17%,1) 67%); /* W3C */
}
.Estilo8 {font-size: 18px}
.Estilo9 {
color: #FFFFFF;
font-weight: bold;
font-size: 18px;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}

-->
</style>
</head>

<body>
<table width="898" border="0" align="center">
<tr>
<td width="202"><div align="left"><img src="LOGO DE TU PAGINA WEB" width="200" height="92" alt="logo" longdesc="logo" /></div></td>
<td width="618" colspan="2"><div align="center" class="Estilo7"><a href="../../../paneldecontrol.php">PANEL DE CONTROL</a></div></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><div align="right" class="Estilo9"><a href="<?php echo $logoutAction ?>">SALIR</a></div></td>
</tr>
<tr>
<td colspan="3" class="fondo"> </td>
</tr>
<tr>
<td colspan="3"><table width="742" border="0">
<tr>
<td width="58"><span class="Estilo2">Usuario:</span></td>
<td width="674"><span class="Estilo6"><?php echo $row_Recordset1['usuario']; ?></span></td>
</tr>
<tr>
<td><span class="Estilo2">Empresa:</span></td>
<td><span class="Estilo1"><?php echo $row_Recordset2['empresa']; ?></span></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3" class="fondo"> </td>
</tr>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td colspan="3"><table width="875" border="0" align="center">
<tr>
<td><table width="237" border="0">
<tr>
<td><span class="Estilo4"><a href="../../../subirclasificado.php"><img src="icons/star-green.png" alt="star" width="24" height="24" longdesc="star" /> Subir Clasificado</a></span></td>
</tr>
</table></td>
<td><table width="237" border="0">
<tr>
<td><span class="Estilo4"><a href="../../../comprar.php"><img src="icons/dollar.png" alt="dollar" width="24" height="24" longdesc="dollar" /> Comprar Paquete</a></span></td>
</tr>
</table></td>
<td><table width="237" border="0">
<tr>
<td><span class="Estilo4"><a href="../../../borrarclasificado.php"><img src="icons/search.png" alt="search" width="24" height="24" longdesc="search" /> Borrar Clasificado</a></span></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="3"><table width="875" border="0" align="center">
<tr>
<td width="239">Numero de Clasificados comprados:</td>
<td width="626">
<div align="left"><span class="Estilo4"><? echo $row_Recordset3['cantidadclasificados'] ?>
</span>  </div></td>
</tr>
<tr>
<td>Numero de Clasificados utilizados:</td>
<td>
<span class="Estilo4"><? echo $cantidadclasificadosusados; ?>
 </span></td>
</tr>
<tr>
<td>Numero de Clasificados pendientes para publicar:</td>
<td>
<span class="Estilo4"><? echo $autorizado ?>
 </span></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2">

<div align="center" class="Estilo1">
<?
if ($autorizado == 0) {
echo "<a href="comprar.php"> >> No posee Saldo para publicar Clasificado, Compre un Paquete. << </a>";
} else {
echo "<a href="subirclasificado1.php"> >> Publicar Su Clasificado << </a>";
}
?>

 </div></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><div align="center"><a href="paneldecontrol.php" target="_self" class="Estilo4">Ir a Panel de Control</a></div></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="3"><p class="Estilo1">Paquetes Clasificados para Inmobiliarias:</p></td>
</tr>
<tr>
<td colspan="3"><p><img src="icons/transportation.png" alt="transporte" width="24" height="24" longdesc="transporte" /> <strong>Paquete Básico:</strong> 5 clasificados (30 días) por $ 50.000. <strong>Valor Comercial</strong>: $ 100.000.</p>
<p><img src="icons/transportation.png" alt="transporte" width="24" height="24" longdesc="transporte" /><strong>Paquete Estándar:</strong> 25 clasificados (60 días) por $ 100.000. <strong>Valor Comercial</strong>: $ 500.000.</p>
<p><img src="icons/transportation.png" alt="transporte" width="24" height="24" longdesc="transporte" /> <strong>Paquete Deluxe: </strong>100 clasificados + Banner de publicidad (90 días) por $ 400.000. <strong>Valor Comercial</strong>: $ 2.000.000.</p>
<p><img src="icons/transportation.png" alt="transporte" width="24" height="24" longdesc="transporte" /> <strong>Paquete Especializado 6 meses:</strong> 1000 clasificados (180 días) por $ 1.000.000. <strong>Valor Comercial</strong>: $ 20.000.000.</p>
<p><img src="icons/transportation.png" alt="transporte" width="24" height="24" longdesc="transporte" /> <strong>Paquete Especializado 1 año:</strong> 2000 clasificados + Banner de publicidad (365 días) por $ 2.000.000. <strong>Valor Comercial</strong>: $ 40.000.000.</p></td>
</tr>
<tr>
<td colspan="3"><p> </p></td>
</tr>
<tr>
<td colspan="3"><p class="Estilo8">Cualquier inquietud favor comunicarse con nosotros al siguiente correo electrónico: [email protected]</p></td>
</tr>
<tr>
<td colspan="3"><p align="center"> </p></td>
</tr>
<tr>
<td colspan="3"><p align="center"><strong>2011© Su-Clasificado.com</strong></p></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset3);

mysql_free_result($Recordset1);

mysql_free_result($Recordset2);

mysql_free_result($Recordset4);
?>
Datos archivados del Taringa! original
0puntos
458visitas
0comentarios
Actividad nueva en Posteamelo
0puntos
2visitas
0comentarios
Dar puntos:

Dejá tu comentario

0/2000

Autor del Post

m
munaterai🇦🇷
Usuario
Puntos0
Posts1
Ver perfil →
PosteameloArchivo Histórico de Taringa! (2004-2017). Preservando la inteligencia colectiva de la internet hispanohablante.

CONTACTO

18 de Septiembre 455, Casilla 52

Chillán, Región de Ñuble, Chile

Solo correo postal

© 2026 Posteamelo.com. No afiliado con Taringa! ni sus sucesores.

Contenido preservado con fines históricos y culturales.