Foros del Web » Programando para Internet » PHP »

subir imagen

Estas en el tema de subir imagen en el foro de PHP en Foros del Web. Hola mi nombre es Fernando estoy realizando un web y tengo el siguiente problema quiero saber si alguien me puede ayudar? este es el script ...
  #1 (permalink)  
Antiguo 20/04/2011, 08:36
Usuario no validado
 
Fecha de Ingreso: febrero-2008
Ubicación: Montevideo
Mensajes: 142
Antigüedad: 16 años, 2 meses
Puntos: 7
De acuerdo subir imagen

Hola mi nombre es Fernando estoy realizando un web y tengo el siguiente problema quiero saber si alguien me puede ayudar?

este es el script del formulario donde subo la imagen y otros datos

articulos.php

Código PHP:
<?php require_once('../Connections/ofertas.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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")) {
  
$insertSQL sprintf("INSERT INTO contenido (id_articulos, Nombre, Articulos, Imagen, Precio, Descuento, Ahorras, Hora, Minutos, Segundos, empresa) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['id_articulos'], "int"),
                       
GetSQLValueString($_POST['Nombre'], "text"),
                       
GetSQLValueString($_POST['Articulos'], "text"),
                       
GetSQLValueString($_POST['Imagen'], "text"),
                       
GetSQLValueString($_POST['Precio'], "text"),
                       
GetSQLValueString($_POST['Descuento'], "text"),
                       
GetSQLValueString($_POST['Ahorras'], "text"),
                       
GetSQLValueString($_POST['Hora'], "date"),
                       
GetSQLValueString($_POST['Minutos'], "date"),
                       
GetSQLValueString($_POST['Segundos'], "date"),
                       
GetSQLValueString($_POST['empresa'], "text"));

  
mysql_select_db($database_ofertas$ofertas);
  
$Result1 mysql_query($insertSQL$ofertas) or die(mysql_error());

  
$insertGoTo "articulo.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=iso-8859-1" />
<title></title>
<style type="text/css">
<!--
#articulos {
    position:absolute;
    left:58px;
    top:38px;
    width:600px;
    height:600px;
    z-index:1;
}
-->
</style>
</head>

<body>
<div id="articulos">
  <form method="post" name="form1" action="<?php echo $editFormAction?>">
    <table align="center">
      <tr valign="baseline">
        <td nowrap align="right">Nombre:</td>
        <td><input type="text" name="Nombre" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right" valign="top">Articulos:</td>
        <td><textarea name="Articulos" cols="50" rows="5"></textarea>
        </td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Imagen:</td>
        <td><input name="Imagen" type="file" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Precio:</td>
        <td><input type="text" name="Precio" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Descuento:</td>
        <td><input type="text" name="Descuento" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Ahorras:</td>
        <td><input type="text" name="Ahorras" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Hora:</td>
        <td><input type="text" name="Hora" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Minutos:</td>
        <td><input type="text" name="Minutos" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Segundos:</td>
        <td><input type="text" name="Segundos" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">Empresa:</td>
        <td><input type="text" name="empresa" value="" size="32"></td>
      </tr>
      <tr valign="baseline">
        <td nowrap align="right">&nbsp;</td>
        <td><input type="submit" value="Insertar registro"></td>
      </tr>
    </table>
    <input type="hidden" name="id_articulos" value="">
    <input type="hidden" name="MM_insert" value="form1">
  </form>
  <p>&nbsp;</p>
</div>
</body>
</html>
y este el formulario donde muestro los datos subidos

articulo.php

Código PHP:
<?php require_once('../Connections/ofertas.php'); ?>
<?php
mysql_select_db
($database_ofertas$ofertas);
$query_articulo "SELECT Nombre, Articulos, Imagen, Precio, Descuento, Ahorras, Hora, Minutos, Segundos, empresa FROM contenido";
$articulo mysql_query($query_articulo$ofertas) or die(mysql_error());
$row_articulo mysql_fetch_assoc($articulo);
$totalRows_articulo mysql_num_rows($articulo);
?><!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=iso-8859-1" />
<title></title>
<style type="text/css">
<!--
.Estilo1 {
    font-family: "Times New Roman", Times, serif;
    font-weight: bold;
    font-size: 44px;
    color: #0066FF;
}
-->
</style>
</head>

<body>
<div id="articulo">
<table width="533" border="0" align="center">
  <tr>
    <td width="129">&nbsp;</td>
    <td width="394"><span class="Estilo1"><?php echo $row_articulo['Nombre']; ?></span></td>
    </tr>
  <tr>
    <td><?php echo $row_articulo['Precio']; ?> <?php echo $row_articulo['Descuento']; ?> <?php echo $row_articulo['Ahorras']; ?></td>
    <td><p><?php echo $row_articulo['Imagen ']; ?> 
      <p><?php echo $row_articulo['Articulos']; ?></p></td>
    </tr>
  <tr>
    <td><?php echo $row_articulo['Hora']; ?></td>
    <td><?php echo $row_articulo['empresa']; ?></td>
    </tr>
</table>
</div>
</body>
</html>
<?php
mysql_free_result
($articulo);
?>
mi problema es que no puedo ver la imagen que subo si alguien me puede ayudar

muchisimas gracias
  #2 (permalink)  
Antiguo 20/04/2011, 09:34
Avatar de memoadian
Colaborador
 
Fecha de Ingreso: junio-2009
Ubicación: <?php echo 'México'?>
Mensajes: 3.696
Antigüedad: 14 años, 9 meses
Puntos: 641
Respuesta: subir imagen

y la imagen se sube? puedes acceder via url? o de plano no se sube, marca algún error? tu script o todo ok

el form aparte de todo debe llevar "enctype="multipart/form-data"

para que pueda subir imágenes, y no veo en ninguna parte que recibas la variable $_FILES para procesar tu imágen

Etiquetas: Ninguno
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 14:20.