Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/07/2011, 11:43
Avatar de NnikoO
NnikoO
 
Fecha de Ingreso: agosto-2008
Ubicación: Rosario
Mensajes: 245
Antigüedad: 15 años, 8 meses
Puntos: 0
Exclamación Problemas para subir archivos!

Hola! de nuevo yo.. mi problema es que tengo un error en el codigo a la hora de subir una imágen en una noticia por medio de un código php. Cuando lo uso en mi pc, en el localhost, funciona de maravilla. Pero cuando lo uso en el servidor web, ya subida la página, me tira error.

fotos_crear.php:
Código PHP:
<?
require("seguridad.php");
    
$_SESSION["autorizado"];
    
    
include(
"config.php");

// 1.- conectar al servidor
$link mysql_connect($servidor$usuario$pass) or die(mysql_error());        
        
// 2.- seleccionar la bd
$bd mysql_select_db($basedato$link) or die(mysql_error());        


if(
$_POST['guardar'])
{
        if(
$_FILES['foto']['error'] != 0
            {
                
                switch (
$_FILES['foto']['error'])
                {
                    case 
1// UPLOAD_ERR_INI_SIZE
                            
$mensaje_error2 " <font color='#FF0000'> El archivo sobrepasa el limite autorizado por el servidor.</font><br>";
                        break;
                    case 
2// UPLOAD_ERR_FORM_SIZE
                            
$mensaje_error2 " <font color='#FF0000'> El archivo sobrepasa el limite autorizado por la aplicacion.</font><br>";
                        break;
                    case 
3// UPLOAD_ERR_PARTIAL
                            
$mensaje_error2 " <font color='#FF0000'> El envio del archivo ha sido suspendido durante la transferencia.</font><br>";
                        break;
                    case 
4// UPLOAD_ERR_NO_FILE
                            
$mensaje_error2 " <font color='#FF0000'> El archivo que ha enviado tiene peso nulo.</font><br>";
                        break;
                }
                
                
$mensaje "<strong><font color='#666'>Hay problemas para subir el archivo. Intente nuevamente. Error: </font></strong>".$mensaje_error2;
                
            }else
            {
                if(
$_FILES['foto']['error'] == 0)
                {
                        
                        
//Nombre de archivo
                        
$nombre substr($_FILES['foto']['name'], 0strrpos($_FILES['foto']['name'],'.'));
                            
                                            
                        
//Extension de archivo
                        
$extension substr($_FILES['foto']['name'], strrpos($_FILES['foto']['name'],'.') );
                        
                        
//Detecta si la extension del archivo es correcta
                        
if((strtolower($extension) == '.gif') OR (strtolower($extension) == '.jpg') OR (strtolower($extension) == '.png') )  
                        {
                        
                            
//Detecta si el tamaño es el correcto
                            
if(($_FILES['foto']['size'] > 0) AND ($_FILES['foto']['size'] < 550000) )
                            {
                        
                                    
$directorio "../galeria/";
                                    
                                    if(isset(
$_FILES['foto']['tmp_name']))
                                    {
                                        if (
is_uploaded_file$_FILES['foto']['tmp_name'])) 
                                        {
                                            
                                            
$nombrecompleto =  $nombre.$extension;
                                            if(
file_exists($directorio.$nombrecompleto)){
                                                
unlink($directorio.$nombrecompleto);
                                            }
                                            
copy($_FILES['foto']['tmp_name'], $directorio.$nombrecompleto);
                                        }  
                                    }
                                    
                                    
// 3.- Selecciono los usuarios que encuetro
                                    
$sql "    
                                                UPDATE noticias SET
                                                descripcion  =    '" 
$_POST['descripcion'] . "', 
                                                foto         =  '" 
$nombrecompleto "'
                                                WHERE idNoticia         = '" 
.$_POST['idNoticia']     . "'";
                                    
                                    
$resultado mysql_query($sql$link) or die(mysql_error());    
                                    
header("Location: noticias_listar.php");
                            }else
                            {
                                
$mensaje "<strong>Error:</strong><font color='#FF0000'> El peso de la imagen que desea subir es muy grande.</font>";
                            }
                        }else
                        {
                            
$mensaje "<strong>Error:</strong><font color='#FF0000'> Esta intentando subir un archivo no valido. Solo se permiten con extension GIF, JPEG o PNG.</font>";
                        }            
                }
            }        
}

?>

<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data">
<table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="49" background="images/header.jpg">&nbsp;</td>
  </tr>
</table>
<table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="32" background="images/menu.jpg"><table width="550" border="0" align="center" cellpadding="0" cellspacing="0" class="shadow">
      <tr>
        <td width="381">&nbsp;</td>
        <td width="169"><a href="noticias_listar.php">Cerrar y volver al listado</a></td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="181" background="images/body 01.jpg"><br />
      <table width="500" height="156" border="0" align="center" cellpadding="2" bordercolor="#003366" style="border-collapse:collapse; color: #000;">
      <tr>
        <td width="151" height="41"><span class="textocargarnoticia">Descripcion: <span class="Estilo4">
          <input name="idNoticia" type="hidden" id="idNoticia" value="<?= $_GET['id']; ?>" />
        </span></span></td>
        <td width="335"><input type="text" name="descripcion" value="" size="52" style="border-width: 1px; border-style: solid; font-size:8pt; color: #666; letter-spacing : 1px;" class="textarea"/></td>
      </tr>
      <tr>
        <td height="70"><span class="textocargarnoticia">Foto:</span></td>
        <td><input type="file" name="foto" value="" style="border-width: 1px; border-style: solid; font-size:8pt; color: #666; letter-spacing : 1px;" class="textarea"/></td>
      </tr>
      <tr>
        <td height="37" colspan="2"><table width="100" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
              <td><input type="submit" name="guardar" value=" Guardar Foto" class="boton" /></td>
            </tr>
          </table></td>
      </tr>
    </table>
      <table width="550" border="0" align="center">
        <tr>
          <td><span class="Estilo41">
            <?= $mensaje?>
            </span></td>
          </tr>
      </table></td>
  </tr>
</table>
<table width="680" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="75" background="images/body 02.jpg">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
<br />
<br />
</form>
Espero que puedan ayudarme. Gracias de antemano.
Un abrazo.

<< niko >>