/** * Get file_name * @param string $source_name * @param string $type * @param string $tmp_name * @param integer $index * @param string $content_range * @param FileUpload $upload * @return string */ public function getFileName($source_name, $type, $tmp_name, $index, $content_range, FileUpload $upload) { $this->pathresolver = $upload->getPathResolver(); $this->filesystem = $upload->getFileSystem(); $extension = pathinfo($source_name, PATHINFO_EXTENSION); return $this->getUniqueFilename($source_name, $type, $index, $content_range, $extension); }
/** * Get file_name * @param string $source_name * @param string $type * @param string $tmp_name * @param integer $index * @param string $content_range * @param Pathresolver $pathresolver * @param Filesystem $filesystem * @return bool|string if $allowDuplicate is set to false and a file with the same Md5'd name exists in the upload directory, then a bool is returned. */ public function getFileName($source_name, $type, $tmp_name, $index, $content_range, FileUpload $upload) { $filename = pathinfo($source_name, PATHINFO_FILENAME); $extension = pathinfo($source_name, PATHINFO_EXTENSION); $md5ConcatenatedName = md5($filename) . "." . $extension; if ($upload->getFileSystem()->doesFileExist($upload->getPathResolver()->getUploadPath($md5ConcatenatedName)) && $this->allowDuplicate === false) { $upload->getFileContainer()->error = "File already exist in the upload directory. Please upload another file or change it's name"; return false; } return $md5ConcatenatedName; }
/** * Get file_name * @param string $source_name * @param string $type * @param string $tmp_name * @param integer $index * @param string $content_range * @param FileUpload $upload * @return string */ public function getFileName($source_name, $type, $tmp_name, $index, $content_range, FileUpload $upload) { $this->filesystem = $upload->getFileSystem(); $this->pathresolver = $upload->getPathResolver(); return $this->getUniqueFilename($source_name, $type, $index, $content_range); }