Foros del Web » Programando para Internet » PHP »

Que Hago Mal En Upload

Estas en el tema de Que Hago Mal En Upload en el foro de PHP en Foros del Web. Tengo este formulario para subir archivo con su respectivo php para procesar, en localhost funciona pero en el servidor no. Resulta que hago el proceso ...
  #1 (permalink)  
Antiguo 13/12/2007, 07:10
Avatar de davincci  
Fecha de Ingreso: enero-2005
Mensajes: 193
Antigüedad: 19 años, 3 meses
Puntos: 0
Exclamación Que Hago Mal En Upload

Tengo este formulario para subir archivo con su respectivo php para procesar, en localhost funciona pero en el servidor no. Resulta que hago el proceso de subir los archivos y hace todo el proceso, hasta me guarda la extension en la base de datos, pero al revisar la carpeta de destino esta desocupada, alguna ayuda por favor de que es lo que hago mal. PDT: las carpetas tienen permisos 777.

Formulario

Código PHP:
<?php

if (!isset($_SESSION)) {

  
session_start();

}

$MM_authorizedUsers "1";

$MM_donotCheckaccess "false";

// *** Restrict Access To Page: Grant or deny access to this page

function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 

  
// For security, start by assuming the visitor is NOT authorized. 

  
$isValid False

  
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 

  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 

  
if (!empty($UserName)) { 

    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 

    // Parse the strings into arrays. 

    
$arrUsers Explode(","$strUsers); 

    
$arrGroups Explode(","$strGroups); 

    if (
in_array($UserName$arrUsers)) { 

      
$isValid true

    } 

    
// Or, you may restrict access to only certain users based on their username. 

    
if (in_array($UserGroup$arrGroups)) { 

      
$isValid true

    } 

    if ((
$strUsers == "") && false) { 

      
$isValid true

    } 

  } 

  return 
$isValid

}



$MM_restrictGoTo "error.php";

if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   

  
$MM_qsChar "?";

  
$MM_referrer $_SERVER['PHP_SELF'];

  if (
strpos($MM_restrictGoTo"?")) $MM_qsChar "&";

  if (isset(
$QUERY_STRING) && strlen($QUERY_STRING) > 0

  
$MM_referrer .= "?" $QUERY_STRING;

  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);

  
header("Location: "$MM_restrictGoTo); 

  exit;

}

?><html>

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<META lang=es content="" name=Keywords>

<META content="" name=Description>

<META content=worldwide name=coverage>

<META content=all name=robots>

<META content=general name=rating>

<META content="" name=revisit-after>

<meta name="distribution" content="local">

</script>

<script language="JavaScript1.2">

<!--

top.window.moveTo(0,0);

if (document.all) {

top.window.resizeTo(screen.availWidth,screen.availHeight);



}

else if (document.layers||document.getElementById) {

if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){

top.window.outerHeight = screen.availHeight;

top.window.outerWidth = screen.availWidth;


}


}


//-->


</script>


<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />

<script type="text/javascript" src="js/prototype.js"></script>

<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>

<script type="text/javascript" src="js/lightbox.js"></script>

<link href="estilo.css" rel="stylesheet" type="text/css">

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<link href="../estilo.css" rel="stylesheet" type="text/css">

<style type="text/css">

<!--

.Estilo1 {font-size: 16pt}

.Estilo2 {font-weight: bold}

-->

</style>

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">


<table width="837" height="462" border="0" align="center" cellpadding="0" cellspacing="0" id="principal">


    <tr>



      <td width="2" height="462" class="leftshadow"></td>



        <td width="831" height="462" valign="top" class="leftbox"><p align="center">&nbsp;</p>

          <p align="center">&nbsp;</p>

          <p align="center">&nbsp;</p>

          <form enctype="multipart/form-data" action="proacad.php" method="POST">

            <label>

            <div align="center">

              <input type="hidden" name="MAX_FILE_SIZE" value="3000000" />

              <br />

<strong>Insertar archivo</strong>:

<input name="archivo" type="file" id="archivo" />

<input type="submit" name="enviar" value="Enviar" />

</div>

            </label>

                                        </form>

          <p>&nbsp;</p>

          </td>
        <td width="4" align="center" valign="top" class="watermark">&nbsp;</td>

  </tr>

</table>

</body>

</html>
Procesador

Código PHP:
<?php

if (!isset($_SESSION)) {

  
session_start();

}

$MM_authorizedUsers "1";

$MM_donotCheckaccess "false";



// *** Restrict Access To Page: Grant or deny access to this page

function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 

  
// For security, start by assuming the visitor is NOT authorized. 

  
$isValid False



  
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 

  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 

  
if (!empty($UserName)) { 

    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 

    // Parse the strings into arrays. 

    
$arrUsers Explode(","$strUsers); 

    
$arrGroups Explode(","$strGroups); 

    if (
in_array($UserName$arrUsers)) { 

      
$isValid true

    } 

    
// Or, you may restrict access to only certain users based on their username. 

    
if (in_array($UserGroup$arrGroups)) { 

      
$isValid true

    } 

    if ((
$strUsers == "") && false) { 

      
$isValid true

    } 

  } 

  return 
$isValid

}



$MM_restrictGoTo "error.php";

if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   

  
$MM_qsChar "?";

  
$MM_referrer $_SERVER['PHP_SELF'];

  if (
strpos($MM_restrictGoTo"?")) $MM_qsChar "&";

  if (isset(
$QUERY_STRING) && strlen($QUERY_STRING) > 0

  
$MM_referrer .= "?" $QUERY_STRING;

  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);

  
header("Location: "$MM_restrictGoTo); 

  exit;

}

?><html>



<head>



<title></title>



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">



<META lang=es content="" name=Keywords>



<META content="" name=Description>



<META content=worldwide name=coverage>



<META content=all name=robots>



<META content=general name=rating>



<META content="1 days" name=revisit-after>



<meta name="distribution" content="local">



</script>



<script language="JavaScript1.2">



<!--



top.window.moveTo(0,0);



if (document.all) {



top.window.resizeTo(screen.availWidth,screen.availHeight);



}



else if (document.layers||document.getElementById) {



if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){



top.window.outerHeight = screen.availHeight;



top.window.outerWidth = screen.availWidth;



}



}



//-->



</script>



<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />



<script type="text/javascript" src="js/prototype.js"></script>



<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>



<script type="text/javascript" src="js/lightbox.js"></script>



<link href="estilo.css" rel="stylesheet" type="text/css">



<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<link href="../estilo.css" rel="stylesheet" type="text/css">

<style type="text/css">

<!--

.Estilo1 {font-size: 16pt}

-->

</style>

</head>



<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">







<table width="837" height="462" border="0" align="center" cellpadding="0" cellspacing="0" id="principal">



    <tr>



      <td width="2" height="462" class="leftshadow"></td>



        <td width="831" height="462" valign="top" class="leftbox"><p align="center">&nbsp;</p>

          <p align="center"><span class="titulos Estilo2 Estilo1">INSERCION DE ARCHIVOS</span></p>

          <p align="center">&nbsp;</p>

          <div align="center">

            <p><strong>Archivo recibido</strong></p>
          </div>

          <?php

define
('HOST''localhost');

define('DB''base');

define('USERNAME''usuario');

define('PASSWORD''123');



$link = @mysql_connect(HOST,USERNAME,PASSWORD);

if (!
$link) {

   die(
'En este momento no hay conexion con la base de datos.');

}

   

mysql_select_db(DB) or die("No se ha seleccionado base de datos.");  

if (isset(
$_POST['enviar'])) {



 

    
$upload_dir '../desaca/';

    
$upload_file $upload_dir $_FILES['archivo']['name'];

    
$archivo $_FILES['archivo']['name'];



    if (
move_uploaded_file($_FILES['archivo']['tmp_name'], $upload_file)) {

          

        
$query "INSERT desaca SET archivo='$archivo'";

        
mysql_query($query);



    } else {

           

    }





}

?>

<p align="center">&nbsp;</p>

          <p align="center">&nbsp;</p>

      <p align="center">&nbsp;</p></td>

        <td width="4" align="center" valign="top" class="watermark">&nbsp;</td>

  </tr>

</table>

</body>

</html>
__________________
Mil gracias por sus enseñanzas.

Davincci
  #2 (permalink)  
Antiguo 13/12/2007, 07:25
Avatar de rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 9 meses
Puntos: 638
Re: Que Hago Mal En Upload

hola, revisaste bien la ruta? es la correcta? otra cosa, prueba poner el valor de $upload_dir entre comillas dobles:
Código PHP:
$upload_dir "../desaca/" 
saludos y suerte
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose
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 21:19.