Skip to content

Instantly share code, notes, and snippets.

@enlacee
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enlacee/dc40e1c162a88139233a to your computer and use it in GitHub Desktop.
Save enlacee/dc40e1c162a88139233a to your computer and use it in GitHub Desktop.
funciones en chamilo :)
<?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;
}
@enlacee
Copy link
Author

enlacee commented Jul 12, 2014

nota con archivos con doble extension, falta mejorar 🍡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment