elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Security Series.XSS. [Cross Site Scripting]


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  Ayuda: Obtener path?
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda: Obtener path?  (Leído 1,584 veces)
t4r0x

Desconectado Desconectado

Mensajes: 92



Ver Perfil
Ayuda: Obtener path?
« en: 22 Febrero 2014, 05:25 am »

Buenas alguien sabe como obtener el path del directorio public_html?
o una solucion a mi problema: desde mi php quiero leer un archivo de texto que se encuentra en www.miweb.com/public_html/subfolder/archivo.txt y el archivo php se encuentra en www.miweb.com/public_html/leer.php pero la funcion fopen me dice error.

gracias!


En línea

#!drvy
Moderador
***
Desconectado Desconectado

Mensajes: 5.850



Ver Perfil WWW
Re: Ayuda: Obtener path?
« Respuesta #1 en: 22 Febrero 2014, 06:21 am »

Tienen que ser directorios internos no urls.

Código
  1. $dir = dirname(__FILE__);
  2. echo $dir;

Esto imprime la ruta del directorio en el que se encuentra el archivo actual.. a partir de ahi puedes hacer

Código
  1. $contenido = file_get_contents($dir.'/subfolder/archivo.txt');
  2. echo $contenido;

Saludos


En línea

t4r0x

Desconectado Desconectado

Mensajes: 92



Ver Perfil
Re: Ayuda: Obtener path?
« Respuesta #2 en: 22 Febrero 2014, 06:47 am »

Hola! intente lo que me dices y me retorna esto:

Código
  1. /home/a1823538/public_html
  2. PHP Error Message
  3.  
  4. Warning: file_get_contents(/home/a1823538/public_html/subfolder/archivo.txt) [function.file-get-contents]: failed to open stream: No such file or directory in /home/a1823538/public_html/ReadTextFile.php on line 6
  5.  
  6. Free Web Hosting
  7.  
  8. PHP Error Message
  9.  
  10. Warning: fopen() [function.fopen]: Filename cannot be empty in /home/a1823538/public_html/ReadTextFile.php on line 9
  11.  
  12. Free Web Hosting
  13.  
  14. PHP Error Message
  15.  
  16. Warning: fread(): supplied argument is not a valid stream resource in /home/a1823538/public_html/ReadTextFile.php on line 10
  17.  
  18. Free Web Hosting
  19.  
  20. PHP Error Message
  21.  
  22. Warning: fclose(): supplied argument is not a valid stream resource in /home/a1823538/public_html/ReadTextFile.php on line 11
  23.  
  24. Free Web Hosting
  25.  

php:
Código
  1. <?php
  2.  
  3.    $dir = dirname(__FILE__);
  4.    echo $dir;
  5.  
  6.    $ruta = file_get_contents($dir.'/subfolder/archivo.txt');
  7.    echo $ruta;    
  8.  
  9. $handle = fopen($ruta,"r");
  10.    $content = fread($handle, filesize($ruta));
  11.    fclose($handle);
  12.  
  13.    echo $content;
  14. ?>
  15.  

Mi host el gratuito de 000webhost puede que sea el problema? he intentado infinidades de cosas llevo unas horas con el problema y buscando y no logro entender porque no puede leer el archivo



« Última modificación: 22 Febrero 2014, 07:25 am por #!drvy » En línea

t4r0x

Desconectado Desconectado

Mensajes: 92



Ver Perfil
Re: Ayuda: Obtener path?
« Respuesta #3 en: 22 Febrero 2014, 07:23 am »

Buenas resolvi el problema, habia cambiado el nombre del .txt y gracias a tu
ayuda ya pude obtener el path correcto muchas gracias!
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
obtener Path
Programación Visual Basic
xAnubiSx 0 1,105 Último mensaje 22 Febrero 2006, 23:16 pm
por xAnubiSx
Obtener Path
Programación Visual Basic
xAnubiSx 5 1,714 Último mensaje 23 Febrero 2006, 18:49 pm
por Ironhorse
Exploitation of [Path Normalization Bug] & [Path Truncation Bug]
Nivel Web
tragantras 6 7,236 Último mensaje 30 Octubre 2010, 23:25 pm
por Enrique357
[Sources code] Obtener Path de un programa con el handle de ventana
Programación Visual Basic
x64core 4 3,062 Último mensaje 29 Junio 2011, 10:19 am
por x64core
obtener path de un input file en PHP?
PHP
Legnak 3 2,740 Último mensaje 22 Junio 2014, 04:15 am
por engel lex
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines