Foros del Web » Programando para Internet » PHP »

SOLUCIONADOR Error: ftp_chdir

Estas en el tema de SOLUCIONADOR Error: ftp_chdir en el foro de PHP en Foros del Web. index.php Código PHP: <?php  include( 'function.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>     <title></title>     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />     <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <p>Lista de Archivos</p> <table class="bg_table" cellspacing="0" cellpadding="0">     <tr>         <td>Nombre</td>         <td>Tama&ntilde;o</td>         <td>Fecha</td>     </tr> <?php $id_ftp ...
  #1 (permalink)  
Antiguo 03/11/2014, 15:04
 
Fecha de Ingreso: octubre-2014
Mensajes: 12
Antigüedad: 9 años, 6 meses
Puntos: 0
SOLUCIONADOR Error: ftp_chdir

index.php
Código PHP:
<?php include('function.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>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<p>Lista de Archivos</p>
<table class="bg_table" cellspacing="0" cellpadding="0">
    <tr>
        <td>Nombre</td>
        <td>Tama&ntilde;o</td>
        <td>Fecha</td>
    </tr>
<?php
$id_ftp
=ConectarFTP(); //Obtiene un manejador y se conecta al Servidor FTP
$ruta=ObtenerRuta(); //Obtiene la ruta actual en el Servidor FTP
$lista=ftp_nlist($id_ftp,$ruta); //Devuelve un array con los nombres de ficheros
$lista=array_reverse($lista); //Invierte orden del array (ordena array)

while ($item=array_pop($lista)) { //Se leen todos los ficheros y directorios del directorio
    
$tamano=number_format(((ftp_size($id_ftp,$item))/1024),2)." Kb";
//Obtiene tamaño de archivo y lo pasa a KB
    
if($tamano=="-0.00 Kb") {// Si es -0.00 Kb se refiere a un directorio

        
$item="<i>".$item."</i>";
        
$tamano="&nbsp;";
        
$fecha="&nbsp;";
    }else{
        
date_default_timezone_set("America/Santiago");
        
$fecha=date("d-m-Y G:i:s"ftp_mdtm($id_ftp,$item));
//Filemtime obtiene la fecha de modificacion del fichero; y date le da el formato de salida
    
}
?>
<tr>
    <td><a href="ftp://192.0.0.1/<?php echo $item ?>"><?php echo $item ?></a></td>
    <td><?php echo $tamano ?></td>
    <td><?php echo $fecha ?></td>
</tr>
<?php ?>
</table>
</body>
</html>
function.php
Código PHP:
<?php
# Cambie estos datos por los de su Servidor FTP
define("SERVER","192.0.0.1"); //IP o Nombre del Servidor
define("PORT",21); //Puerto
define("USER","xxx"); //Nombre de Usuario
define("PASSWORD","xxx"); //Contraseña de acceso
define("MODO",true); //Activa modo pasivo

function ConectarFTP(){
//Permite conectarse al Servidor FTP
$id_ftp=ftp_connect(SERVER,PORT);    //Obtiene un manejador del Servidor FTP
ftp_login($id_ftp,USER,PASSWORD);    //Se loguea al Servidor FTP
ftp_pasv($id_ftp,MODO);    //Establece el modo de conexión
return $id_ftp//Devuelve el manejador a la función
}

function 
ObtenerRuta(){
//Obriene ruta del directorio del Servidor FTP (Comando PWD)
$id_ftp=ConectarFTP(); //Obtiene un manejador y se conecta al Servidor FTP
ftp_chdir($id_ftp"ftp_shares/boletas");
$Directorio=ftp_pwd($id_ftp); //Devuelve ruta actual p.e. "/home/willy"
ftp_quit($id_ftp); //Cierra la conexion FTP
return $Directorio//Devuelve la ruta a la función
}
?>
Resultado


pero dice que el nombre es ftp_shares/boletas/132626.PDF y quita la ruta ftp_shares para que cambia por SOLO EL NOMBRE , quiero que pide SOLO EL NOMBRE por ejemplo solo NOMBRE 132626.PDF no mas..

problema ftp_chdir($id_ftp, "ftp_shares/boletas");

ayudame plis

Etiquetas: fecha, html
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 19:49.