Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/08/2008, 20:01
lanbinder
 
Fecha de Ingreso: julio-2008
Mensajes: 14
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Problema con carga desde formulario

Muchas Gracias GatorV... Me Sirvio y ademas arregle un par de cositas mas q tenia mal... el problema es q ahora avanzando de a poco en este raro lenguaje de php... me tira este error cuando quiero cargar la img del producto...

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'img/7.jpg' for writing: No such file or directory in C:\wamp\www\Down01\Admin\Productos\imagen2.php on line 110


el código de image2.php es...

Código PHP:
<?php require_once('../../Connections/cnx.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 "'" "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;
}
}

mysql_select_db($database_cnx$cnx);
$query_rsd_id_usuario "SELECT MAX(id_usuario) as id_usuario FROM login";
$rsd_id_usuario mysql_query($query_rsd_id_usuario$cnx) or die(mysql_error());
$row_rsd_id_usuario mysql_fetch_assoc($rsd_id_usuario);
$totalRows_rsd_id_usuario mysql_num_rows($rsd_id_usuario);
?>
<?php
//variables
$nombre=$_FILES['archivo']['name'];
$archivo_size=$_FILES['archivo']['size'];
$archivo_type=$_FILES['archivo']['type'];
$info getimagesize($_FILES['archivo']['tmp_name']);
$ruta="img/";
$limite="si";
$size="25000";
$tipo1="image/jpeg";
$tipo2="image/gif";
$tipo3="image/png";


if (
$archivo_type==$tipo1){
$nombre $row_rsd_id_usuario['id_usuario'].".jpg";
}
if (
$archivo_type==$tipo2){
$nombre $row_rsd_id_usuario['id_usuario'].".gif";
}
if (
$archivo_type==$tipo3){
$nombre $row_rsd_id_usuario['id_usuario'].".png";
}

// Obtenemos la información de la imagen
$im_info getimagesize($_FILES['archivo'] ['tmp_name']);
// Evaluamos si es GIF(1) o JPEG(2)
// y creamos la imagen en GD
switch($im_info[2]) {
  case 
1:
    
$imagen imagecreatefromgif($_FILES['archivo'] ['tmp_name']); 
    
    break;
  case 
2:
    
$imagen imagecreatefromjpeg($_FILES['archivo'] ['tmp_name']);
    
     break;
  case 
3:
    
$imagen imagecreatefrompng($_FILES['archivo'] ['tmp_name'])
    
    ; break;
  
// etcétera //
  
}
  

// Definimos la medida máxima
$th_max 120// de la muestra (thumbnail)

// Evaluamos si la imagen es horizontal
if($im_info[0]>$im_info[1]) {
    
// Definimos las medidas de las imagenes
    
$th_w $th_max;
    
$th_h = ($im_info[1]/$im_info[0])*$th_max;
   
    } else {
    
$th_w = ($im_info[0]/$im_info[1])*$th_max;
    
$th_h $th_max;
   
    }

// Creamos las imágenes
$thumb imagecreatetruecolor($th_w,$th_h);


// Copiamos la original escalada
imagecopyresampled($thumb,$imagen,0,0,0,0$th_w,$th_h,imagesx($imagen),imagesy($imagen));



// Destruimos la imagen original
imagedestroy($imagen);

    
// Damos salida a nuestros archivos
imagejpeg($thumb,$ruta.$nombre,60);


// Destruimos las imagenes temporales
imagedestroy($thumb);

 
//header(sprintf("Location: %s", "dos.php"));
 
$log.="";
 if (
$nombre == ""){
    
$log.="No se seleccionó ningún archivo";
    }

                    if (
file_exists($ruta.$nombre)){
                        
$log.= "El archivo se subió con éxito";
                        

                
                    }else{
                        
$log.="No es un archivo autorizado";
                        }
                    
?>
<p align="center"><span class="style1"><?php echo $log ?></span></p>
<p><a href="Productos.php">volver a productos</a></p>
<p><a href="imagen1.php">intentar nuevamente</a></p>
<p class="style1">&nbsp;</p>
</body>

</html>
<?php
mysql_free_result
($rsd_id_usuario);
?>
y en verdad... no entiendo nada ya que mi fasinacion es con el 3d y la animacion... esto lo hago por obligacion... Y no entiendo nada!!!!!!!!!!!!!

Gracias! Nuevamente!!

Última edición por lanbinder; 07/08/2008 a las 20:05 Razón: estaba mal el copiado