/** * Get unique but consistent name * @param string $name * @param string $type * @param integer $index * @param array $content_range * @param string $extension * @return string */ protected function getUniqueFilename($name, $type, $index, $content_range, $extension) { $name = $this->generateRandom() . "." . $extension; while ($this->filesystem->isDir($this->pathresolver->getUploadPath($name))) { $name = $this->generateRandom() . "." . $extension; } $uploaded_bytes = Util::fixIntegerOverflow(intval($content_range[1])); while ($this->filesystem->isFile($this->pathresolver->getUploadPath($name))) { if ($uploaded_bytes == $this->filesystem->getFilesize($this->pathresolver->getUploadPath($name))) { break; } $name = $this->generateRandom() . "." . $extension; } return $name; }