Friday, April 8, 2016

rename file when upload[kcfinder]

before:
protected function normalizeFilename($filename) {

        if (isset($this->config['filenameChangeChars']) &&
            is_array($this->config['filenameChangeChars'])
        )
            $filename = strtr($filename, $this->config['filenameChangeChars']);

        if (isset($this->config['_normalizeFilenames']) && $this->config['_normalizeFilenames'])
            $filename = file::normalizeFilename($filename);

        return $filename;
    }



after:

protected function normalizeFilename($filename) {

        if (isset($this->config['filenameChangeChars']) &&
            is_array($this->config['filenameChangeChars'])
        )
            $filename = strtr($filename, $this->config['filenameChangeChars']);

        if (isset($this->config['_normalizeFilenames']) && $this->config['_normalizeFilenames'])
            $filename = file::normalizeFilename($filename);


        $path_parts = pathinfo($filename);
        $ext = strtolower($path_parts['extension']);
        return uniqid() . '.' . $ext;

    }

No comments:

Post a Comment