Created
February 8, 2017 16:48
-
-
Save inazense/9f5049357fa2e8f51f131cac9359e156 to your computer and use it in GitHub Desktop.
Cargar ficheros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Librería encargada de trabajar con ficheros | |
* | |
* @author Inazio | |
*/ | |
class Ficheros { | |
/** | |
* Carga en un array los ficheros de un directorio pasado por parámetro. | |
* @param string $ruta directorio de la carpeta donde extraer los ficheros | |
* @return array con la ruta de los ficheros o NULL si directorio inválido | |
*/ | |
public function cargarFicheros($ruta){ | |
// Compruebo si el parámetro pasado es una ruta | |
if (is_dir($ruta)){ | |
// Abro un gestor de directorios | |
$gestor = opendir($ruta); | |
$ficheros = array(); | |
// Recorro archivos del directorio | |
while(($archivo = readdir($gestor)) !== false){ | |
if (is_file($ruta . "/" . $archivo)){ | |
$ficheros = $ruta . "/" . $archivo; | |
array_push($ficheros, $imagen); | |
} | |
} | |
closedir($gestor); | |
return $ficheros; | |
} | |
else{ | |
return NULL; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment