Ejemplo n.º 1
0
function ew_UniqueFilename($folder, $orifn)
{
    if ($orifn == "") {
        $orifn = ew_DefaultFileName();
    }
    $orifn = str_replace(" ", "_", $orifn);
    $orifn = strtolower(basename($orifn));
    $destpath = $folder . $orifn;
    $newfn = $orifn;
    $i = 1;
    if (!file_exists($folder)) {
        if (!ew_CreateFolder($folder)) {
            die("Folder does not exist: " . $folder);
        }
    }
    while (file_exists(ew_Convert(EW_ENCODING, EW_FILE_SYSTEM_ENCODING, $destpath))) {
        $file_extension = strtolower(strrchr($orifn, "."));
        $file_name = basename($orifn, $file_extension);
        $newfn = $file_name . "({$i})" . $file_extension;
        $destpath = $folder . $newfn;
        $i++;
    }
    return $newfn;
}
Ejemplo n.º 2
0
function ew_UniqueFilename($folder, $oriFilename)
{
    if ($oriFilename == "") {
        $oriFilename = ew_DefaultFileName();
    }
    $oriFilename = str_replace(" ", "_", $oriFilename);
    $oriFilename = strtolower(basename($oriFilename));
    $destFullPath = $folder . $oriFilename;
    $newFilename = $oriFilename;
    $i = 1;
    if (!file_exists($folder)) {
        if (!ew_CreateFolder($folder)) {
            die("Folder does not exist: " . $folder);
        }
    }
    while (file_exists($destFullPath)) {
        $file_extension = strtolower(strrchr($oriFilename, "."));
        $file_name = basename($oriFilename, $file_extension);
        $newFilename = $file_name . "({$i})" . $file_extension;
        $destFullPath = $folder . $newFilename;
        $i++;
    }
    return $newFilename;
}