Comunidad oficial de diseñadores web, web developers y Webmasters. Aqui podemos tratar temas actuales sobre diseño y tecnología. Podemos compartir y actualizarnos. Photoshop, Flash, PHP, ASP, Java, HTML, CSS, MySQL, CMS, etc. Unite YA y lee los Sticky

Ver más
  • 13,065 Miembros
  • 9,531 Temas
  • 3,449 Seguidores
  • 0

formulario para subir imagenes con dreamweaver.

Hola, mi nombre es fernando soy de montevideo (Uruguay), me presento porque es la primera ves que escribo en esta comunidad..


ando en busca de ayuda porque se como hacer el formulario para subir las imagenes.

pero lo que no logro es poder ver las mismas.

por eso vengo por aqui en busca de ayuda..

les dejo los script para ver si alguno se da cuenta a que se debe

esta es la base de datos :

CREATE TABLE IF NOT EXISTS `catalogo` (   `Referencia` int(11) NOT NULL,   `Imagen` varchar(60) NOT NULL,   `Tipo` varchar(30) NOT NULL,   `Precio` double NOT NULL,   `Nombre` varchar(100) NOT NULL,   `Descripcion` varchar(100) NOT NULL,   PRIMARY KEY (`Referencia`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
formulario.php

<?php require_once('Connections/con_imag.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['fleImagen']['tmp_name'])) { // verifica haya sido cargado el archivo         $ruta= "images/$tipo_prod/".$_FILES['fleImagen']['name'];         move_uploaded_file($_FILES['fleImagen']['tmp_name'], $ruta);     }        $insertSQL = sprintf("INSERT INTO catalogo (Referencia, Imagen, Tipo, Precio, Nombre, Descripcion) VALUES (%s, %s, %s, %s, %s, %s)",                        GetSQLValueString($_POST['txtReferencia'], "int"),                        GetSQLValueString($ruta, "text"),                        GetSQLValueString($_POST['lstTipo'], "text"),                        GetSQLValueString($_POST['txtPrecio'], "double"),                        GetSQLValueString($_POST['txtNombre'], "text"),                        GetSQLValueString($_POST['txtDescripcion'], "text"));    mysql_select_db($database_con_imag, $con_imag);   $Result1 = mysql_query($insertSQL, $con_imag) or die(mysql_error());    $insertGoTo = "ingreso_exitoso.php";   if (isset($_SERVER['QUERY_STRING'])) {     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";     $insertGoTo .= $_SERVER['QUERY_STRING'];   }   header(sprintf("Location: %s", $insertGoTo)); } ?> <!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>Documento sin título</title> </head>  <body> <form action="<?php echo $editFormAction?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">   <table width="626" border="1">     <tr>       <td width="152"><strong>Referencia:</strong></td>       <td width="458"><label for="txtReferencia"></label>       <input type="text" name="txtReferencia" id="txtReferencia" /></td>     </tr>     <tr>       <td><strong>Imagen:</strong></td>       <td><label for="fleImagen"></label>       <input type="file" name="fleImagen" id="fleImagen" /></td>     </tr>     <tr>       <td><strong>Tipo:</strong></td>       <td><label for="lstTipo"></label>         <select name="lstTipo" id="lstTipo">           <option value="camisetas" selected="selected">Camisetas</option>           <option value="accesorios">Accesorios</option>       </select></td>     </tr>     <tr>       <td><strong>Precio:</strong></td>       <td><label for="txtPrecio"></label>       <input type="text" name="txtPrecio" id="txtPrecio" /></td>     </tr>     <tr>       <td><strong>Nombre:</strong></td>       <td><label for="txtNombre"></label>       <input type="text" name="txtNombre" id="txtNombre" /></td>     </tr>     <tr>       <td><strong>Descripción:</strong></td>       <td><label for="txtDescripcion"></label>       <textarea name="txtDescripcion" id="txtDescripcion" cols="45" rows="5"></textarea></td>     </tr>   </table>   <p>     <input type="submit" name="button" id="button" value="Enviar" />   </p>   <input type="hidden" name="MM_insert" value="form1" /> </form> </body> </html>

ingreso_exitoso.php

<!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>Documento sin título</title> </head>  <body> El dato ha sido ingresado correctamente. </body> </html>

catalogo.php

<?php require_once('Connections/con_imag.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; } }  $maxRows_catalogo_imag 10$pageNum_catalogo_imag 0; if (isset($_GET['pageNum_catalogo_imag'])) {   $pageNum_catalogo_imag $_GET['pageNum_catalogo_imag']; } $startRow_catalogo_imag $pageNum_catalogo_imag $maxRows_catalogo_imag;  mysql_select_db($database_con_imag$con_imag); $query_catalogo_imag "SELECT * FROM catalogo"$query_limit_catalogo_imag sprintf("%s LIMIT %d, %d"$query_catalogo_imag$startRow_catalogo_imag$maxRows_catalogo_imag); $catalogo_imag mysql_query($query_limit_catalogo_imag$con_imag) or die(mysql_error()); $row_catalogo_imag mysql_fetch_assoc($catalogo_imag);  if (isset($_GET['totalRows_catalogo_imag'])) {   $totalRows_catalogo_imag $_GET['totalRows_catalogo_imag']; } else {   $all_catalogo_imag mysql_query($query_catalogo_imag);   $totalRows_catalogo_imag mysql_num_rows($all_catalogo_imag); } $totalPages_catalogo_imag ceil($totalRows_catalogo_imag/$maxRows_catalogo_imag)-1?> <!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>Documento sin título</title> </head>  <body> <table border="1">   <tr>     <td>Referencia</td>     <td>Imagen</td>     <td>Tipo</td>     <td>Precio</td>     <td>Nombre</td>     <td>Descripcion</td>   </tr>   <?php do { ?>     <tr>       <td><?php echo $row_catalogo_imag['Referencia']; ?></td>       <td><img src="<?php echo $row_catalogo_imag['Imagen']; ?>" / ></td>       <td><?php echo $row_catalogo_imag['Tipo']; ?></td>       <td><?php echo $row_catalogo_imag['Precio']; ?></td>       <td><?php echo $row_catalogo_imag['Nombre']; ?></td>       <td><?php echo $row_catalogo_imag['Descripcion']; ?></td>     </tr>     <?php } while ($row_catalogo_imag mysql_fetch_assoc($catalogo_imag)); ?> </table> </body> </html> <?php mysql_free_result($catalogo_imag); ?>


bueno si alguien se dan cuenta
muchas gracias!!!

gracias a todos!!! y disculpen
  • 0
  • 0Calificación
  • 0Seguidores
  • 160Visitas
  • 0Favoritos

9 respuestas

@DjKaissar dijo Hace más de 7 meses:



existe el bbc code

@clon_de_eze dijo Hace más de 7 meses:

usa las etiquetas [ code]

@elvago9 dijo Hace más de 7 meses:

Pone el código entre [code*][/code*].

@Shavo2 dijo Hace más de 7 meses:

Salu2 dos cosas revisa en mysql que al guardar las imagenes guarde la extension q tenga sino es eso
guardas las imagenes en una carpeta esa carpeta esta en la misma carpeta q el script

@HeinrichB dijo Hace más de 7 meses:

El problema es que si estás utilizando blob no puedes mostrar así las imágenes, tienes que hacer un script extra que se encargará de convertir los datos de la base de datos en imagen, un script a la rápida:

imagen.php
<?php
 $link 
mysql_connect($dbhost,$dbuser,$dbpassword) or die(mysql_error($link));
 
mysql_select_db($dbname,$link) or die(mysql_error($link));
 
 
$sql "SELECT imagen FROM tabla WHERE id={$_GET['id']}";
 
$resmysql_query($sql$link);
 
 
$datos mysql_fetch_array($res);
 
 
header("Content-Type: image/jpeg");
 echo 
$datos['imagen'];
?>


Y así en tu código para mostrar tendrías que llamar a la imagen como:
<img src="imagen.php?id=<?php echo $row_catalogo_imag['Id']; ?>" / >

@Shavo2 dijo Hace más de 7 meses:

Te lo pongo asi en vez de guardar las imagenes guarda el path de la imagen en el server la imagen la copias a una carpeta del servidor el campo en la bd que sea varchar cuando guardes tendrias algo como esto :

imagenes/mi_imagen.jpg

donde imagenes es la carpeta donde se encuentran las imagenes en el servidor ahora al llamarla solo pones el tag <img src="<?php echo $row['imagen']?>"/> de esa forma te lo mostrara sino entiendes te paso un script q hize para esto

Tienes que ser miembro para responder en este tema