Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] subir imagenes php y mysql por dreamweaver

Estas en el tema de subir imagenes php y mysql por dreamweaver en el foro de PHP en Foros del Web. Bueno dia Como subir imágenes php y mysql por programas adobe dreamweaver cs5.5 php codigo $_FILES vale? Código PHP: <?php  require_once( 'Connections/wordpress.php' );  ?> <?php ...
  #1 (permalink)  
Antiguo 18/09/2013, 02:59
 
Fecha de Ingreso: abril-2013
Mensajes: 39
Antigüedad: 11 años
Puntos: 0
subir imagenes php y mysql por dreamweaver

Bueno dia
Como subir imágenes php y mysql por programas adobe dreamweaver cs5.5
php codigo $_FILES vale?
Código PHP:
<?php require_once('Connections/wordpress.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$tipo_prod $_POST["lstTipo"];

//Guardar imagen
if(is_uploaded_file($_FILES['imagenes']['tmp_name'])) { // verifica haya sido cargado el archivo
$ruta“imagenes/$tipo_prod/.$_FILES['fleImagen']['name'];
move_uploaded_file($_FILES['imagenes']['tmp_name'], $ruta);
}
    
  
$insertSQL sprintf("INSERT INTO wp_productos (nombre, des, precio, referencia, imagenes, imagenes2, imagenes3, imagenes4) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['des'], "text"),
                       
GetSQLValueString($_POST['precio'], "double"),
                       
GetSQLValueString($_POST['referencia'], "text"),
                       
GetSQLValueString($_POST['imagenes'], "text"),
                       
GetSQLValueString($_POST['imagenes2'], "text"),
                       
GetSQLValueString($_POST['imagenes3'], "text"),
                       
GetSQLValueString($_POST['imagenes4'], "text"));

  
mysql_select_db($database_wordpress$wordpress);
  
$Result1 mysql_query($insertSQL$wordpress) or die(mysql_error());

  
$insertGoTo "index.php?page_id=13";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

?>
  #2 (permalink)  
Antiguo 18/09/2013, 03:10
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: subir imagenes php y mysql por dreamweaver

Podrías concretar que es lo que no sabes hacer o lo que no entiendes....

en serio NO has encontrado ningún post donde se den ejemplos de como subir imágenes....???
__________________
Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados.
  #3 (permalink)  
Antiguo 18/09/2013, 03:15
 
Fecha de Ingreso: abril-2013
Mensajes: 39
Antigüedad: 11 años
Puntos: 0
Respuesta: subir imagenes php y mysql por dreamweaver

tu sabes imágenes guardar solo archivo "imagenes"
  #4 (permalink)  
Antiguo 18/09/2013, 05:24
Avatar de JavierB
Colaborador
 
Fecha de Ingreso: febrero-2002
Ubicación: Madrid
Mensajes: 25.052
Antigüedad: 22 años, 2 meses
Puntos: 772
Respuesta: subir imagenes php y mysql por dreamweaver

Ahora sí que has terminado de aclararlo...
  #5 (permalink)  
Antiguo 18/09/2013, 07:45
Avatar de loncho_rojas
Colaborador
 
Fecha de Ingreso: octubre-2008
Ubicación: En el mejor lugar del mundo
Mensajes: 2.704
Antigüedad: 15 años, 6 meses
Puntos: 175
Respuesta: subir imagenes php y mysql por dreamweaver

You're drunk man? LOL

Tell us more about your problem. We can't understand you.

__________________
Ayudo con lo que puedo en el foro, y solo en el foro.. NO MENSAJES PRIVADOS.. NO EMAILS NI SKYPE u OTROS.

Antes de hacer un TOPICO piensa si puedes hallarlo en Google o en el Buscador del Foro...
  #6 (permalink)  
Antiguo 18/09/2013, 07:59
Avatar de pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: subir imagenes php y mysql por dreamweaver

Cita:
Iniciado por camilomascarell1987 Ver Mensaje
tu sabes imágenes guardar solo archivo "imagenes"
WAT

Aquí no usamos Dreamweaver, aquí programamos PHP como los hombres, a mano todo nuestro código y con el manual en la mano.

¿En qué te podemos ayudar que no tenga que ver con Dreamweaver y sí con código PHP?
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.
  #7 (permalink)  
Antiguo 19/09/2013, 03:10
 
Fecha de Ingreso: abril-2013
Mensajes: 39
Antigüedad: 11 años
Puntos: 0
Respuesta: subir imagenes php y mysql por dreamweaver

yo hecho subir imagenes y mysql todos bien por fin
Código PHP:
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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;
}
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$tipo_prod $_POST["lstTipo"];

//Guardar imagen
$uploads_dir '/imagenes';
foreach (
$_FILES["imagenes"]["error"] as $key => $error) {
    if (
$error == UPLOAD_ERR_OK) {
        
$tmp_name $_FILES["imagenes"]["tmp_name"][$key];
        
$name $_FILES["imagenes"]["name"][$key];
        
move_uploaded_file($tmp_name"$uploads_dir/$name");
    }
}
    
  
$insertSQL sprintf("INSERT INTO wp_productos (nombre, des, precio, referencia, imagenes, imagenes2, imagenes3, imagenes4) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['nombre'], "text"),
                       
GetSQLValueString($_POST['des'], "text"),
                       
GetSQLValueString($_POST['precio'], "double"),
                       
GetSQLValueString($_POST['referencia'], "text"),
                       
GetSQLValueString($_FILES['imagen']['name'], "text"),
                       
GetSQLValueString($_POST['imagenes2'], "text"),
                       
GetSQLValueString($_POST['imagenes3'], "text"),
                       
GetSQLValueString($_POST['imagenes4'], "text"));

if (
$_FILES["imagen"]["error"] > 0){
  echo 
"ha ocurrido un error";
} else {
  
//ahora vamos a verificar si el tipo de archivo es un tipo de imagen permitido.
  //y que el tamano del archivo no exceda los 100kb
  
$permitidos = array("image/jpg""image/jpeg""image/gif""image/png");
  
$limite_kb 2000;
  
  if (
in_array($_FILES['imagen']['type'], $permitidos) && $_FILES['imagen']['size'] <= $limite_kb 1024){
    
//esta es la ruta donde copiaremos la imagen
    //recuerden que deben crear un directorio con este mismo nombre
    //en el mismo lugar donde se encuentra el archivo subir.php
    
$ruta "imagenes/" $_FILES['imagen']['name'];
    
//comprobamos si este archivo existe para no volverlo a copiar.
    //pero si quieren pueden obviar esto si no es necesario.
    //o pueden darle otro nombre para que no sobreescriba el actual.
    
if (!file_exists($ruta)){
      
//aqui movemos el archivo desde la ruta temporal a nuestra ruta
      //usamos la variable $resultado para almacenar el resultado del proceso de mover el archivo
      //almacenara true o false
      
$resultado = @move_uploaded_file($_FILES["imagen"]["tmp_name"], $ruta);
      if (
$resultado){
        
$nombre $_FILES['imagen']['name'];
        echo 
"el archivo ha sido movido exitosamente";
      } else {
        echo 
"ocurrio un error al mover el archivo.";
      }
    } else {
      echo 
$_FILES['imagen']['name'] . ", este archivo existe";
    }
  } else {
    echo 
"archivo no permitido, es tipo de archivo prohibido o excede el tamano de $limite_kb Kilobytes";
  }
}

  
mysql_select_db($database_wordpress$wordpress);
  
$Result1 mysql_query($insertSQL$wordpress) or die(mysql_error());

  
$insertGoTo "index.php?page_id=13";
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}

?>

Etiquetas: dreamweaver, html, imagenes, mysql, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 22:52.