Ver Mensaje Individual
  #14 (permalink)  
Antiguo 24/05/2012, 19:30
ofertasdiarias
 
Fecha de Ingreso: marzo-2011
Mensajes: 115
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: subir imagen segun sesion ¿?

JAJAJ LOGRE QUE QUE EL NOMBRE DE LA IMAGEN SE VEA POR USUARIO EN LA BASE DE DATOS.

OSEA SI FERNANDO SUBE UNA IMAGEN LE APAREZCA SOLO A EL JAJJAA AHORA TENGO OTRO PROBLEMITA QUE ANTES NO TENIA, NO PUEDO HACER QUE SE GUARDE LA IMAGEN EN LA CARPETA Y SI LOGRO QUE LA IMAGEN SE VEA NO ME APARECE EN LA BASE DE DATOS¨?


LES DEJO EL SCRIPT PARA VER SI ALGUNO SE DA CUENTA Y ME PUEDE AYUDAR

Código PHP:
Ver original
  1. <p>&nbsp;</p>
  2. <?php require_once('Connections/hoysale.php'); ?>
  3. <?php
  4. if (!function_exists("GetSQLValueString")) {
  5. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  6. {
  7.   $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.  
  9.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  10.  
  11.   switch ($theType) {
  12.     case "text":
  13.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  14.       break;    
  15.     case "long":
  16.     case "int":
  17.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  18.       break;
  19.     case "double":
  20.       $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  21.       break;
  22.     case "date":
  23.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  24.       break;
  25.     case "defined":
  26.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  27.       break;
  28.   }
  29.   return $theValue;
  30. }
  31. }
  32.  
  33. $editFormAction = $_SERVER['PHP_SELF'];
  34. if (isset($_SERVER['QUERY_STRING'])) {
  35.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  36. }
  37.  
  38. if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  39.   //Guardar imagen
  40.     if(is_uploaded_file($_FILES['Imagen']['tmp_name'])) { // verifica haya sido cargado el archivo
  41.     $ruta= "imagenes/".$_FILES['Imagen']['name'];
  42.     move_uploaded_file($_FILES['Imagen']['tmp_name'], $ruta);
  43.     }
  44.   $updateSQL = sprintf("UPDATE registrarse SET imagen=%s WHERE id_user=%s",
  45.                        GetSQLValueString($ruta, "text"),
  46.                        GetSQLValueString($_POST['id_user'], "int"));
  47.  
  48.   mysql_select_db($database_hoysale, $hoysale);
  49.   $Result1 = mysql_query($updateSQL, $hoysale) or die(mysql_error());
  50.  
  51.   $updateGoTo = "subio.php";
  52.   if (isset($_SERVER['QUERY_STRING'])) {
  53.     $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  54.     $updateGoTo .= $_SERVER['QUERY_STRING'];
  55.   }
  56.   header(sprintf("Location: %s", $updateGoTo));
  57. }
  58.  
  59. $colname_Recordset1 = "-1";
  60. if (isset($_SESSION['MM_id_user'])) {
  61.   $colname_Recordset1 = $_SESSION['MM_id_user'];
  62. }
  63. mysql_select_db($database_hoysale, $hoysale);
  64. $query_Recordset1 = sprintf("SELECT * FROM registrarse WHERE id_user = %s", GetSQLValueString($colname_Recordset1, "int"));
  65. $Recordset1 = mysql_query($query_Recordset1, $hoysale) or die(mysql_error());
  66. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  67. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  68.  
  69. mysql_free_result($Recordset1);
  70. ?>
  71. <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  72.   <table align="center">
  73.     <tr valign="baseline">
  74.       <td nowrap align="right">Imagen:</td>
  75.       <td><input type="file" name="imagen" value="<?php echo htmlentities($row_Recordset1['imagen'], ENT_COMPAT, ''); ?>" size="32"></td>
  76.     </tr>
  77.     <tr valign="baseline">
  78.       <td nowrap align="right">&nbsp;</td>
  79.       <td><input type="submit" value="Actualizar registro"></td>
  80.     </tr>
  81.   </table>
  82.   <input type="hidden" name="MM_update" value="form1">
  83.   <input type="hidden" name="id_user" value="<?php echo $row_Recordset1['id_user']; ?>">
  84. </form>