Last active
August 29, 2015 14:03
-
-
Save enlacee/dc40e1c162a88139233a to your computer and use it in GitHub Desktop.
funciones en chamilo :)
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 | |
function _uniqueFileInDirectory($pathFile) | |
{ | |
$rs = FALSE; | |
$pathFile = str_replace('\\', '/', $pathFile); // valid path if is format windows | |
$ext = pathinfo($pathFile, PATHINFO_EXTENSION); | |
$file = substr(strrchr($pathFile, "/"), 1); | |
$fileLessExt = str_replace(".$ext", '', $file); | |
$path = str_replace($file, '', $pathFile); | |
$nb = ''; | |
$nbCount = 0; | |
while (file_exists($path.$fileLessExt.$nb.".$ext")) { | |
$nbCount += 1; | |
$nb = "_$nbCount"; | |
} | |
$rs = $fileLessExt.$nb.".$ext"; | |
return $rs; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nota con archivos con doble extension, falta mejorar 🍡