Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/03/2011, 08:58
Avatar de T4ke0veR
T4ke0veR
 
Fecha de Ingreso: agosto-2007
Ubicación: Quito - Ecuador
Mensajes: 1.720
Antigüedad: 17 años, 6 meses
Puntos: 28
Insertar imágenes

Saludos,
Estoy retomando la programación y ando desarrollando un sistema donde las personas ingresen sus productos e imagenes.. ahora bien, siempre lo habia desarrollado de una manera muy básica y ahora me gustaria que cuando yo insertara esas imágenes el sistema les cambiara el nombre si ya existe alguna con ese nombre... asi lo desarrollo yo...

Código PHP:
<?php require_once('../Connections/azimut.php'); ?>

<?php

include_once("fckeditor/fckeditor.php") ;

?>

<?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 "'" "''";

      break;    

    case 
"long":

    case 
"int":

      
$theValue = ($theValue != "") ? intval($theValue) : "''";

      break;

    case 
"double":

      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "''";

      break;

    case 
"date":

      
$theValue = ($theValue != "") ? "'" $theValue "'" "''";

      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")) {

//imagenes

$ediciondir'../galeria/';  

$uploaddir=$ediciondir;

if (!
is_dir($ediciondir)) {     mkdir($uploaddir0777);    }

move_uploaded_file($_FILES['foto']['tmp_name'], $uploaddir $_FILES['foto']['name']);    

$filename $_FILES['foto']['name'];



  
$insertSQL sprintf("INSERT INTO galeria (id, cat, cod, nombre, descripcion, foto) VALUES (%s, %s, %s, %s, %s, %s)",

                       
GetSQLValueString($_POST['id'], "int"),

                       
GetSQLValueString($_POST['cat'], "int"),

                       
GetSQLValueString($_POST['cod'], "text"),

                       
GetSQLValueString($_POST['nombre'], "text"),

                       
GetSQLValueString($_POST['descripcion'], "text"),

                       
GetSQLValueString($filename"text"));



  
mysql_select_db($database_azimut$azimut);

  
$Result1 mysql_query($insertSQL$azimut) or die(mysql_error());



  
$insertGoTo "list_accesorios.php";

  if (isset(
$_SERVER['QUERY_STRING'])) {

    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";

    
$insertGoTo .= $_SERVER['QUERY_STRING'];

  }

  
header(sprintf("Location: %s"$insertGoTo));



}?
alguien podria ayudarme???

Gracias de antemano!
__________________
Diseño gráfico, Web, imagen corporativa, publicidad ...