Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Verschiebt eine hochgeladene Datei ins Upload-Verzeichnis mit einem eigenen
- * Namen.
- *
- * @author Jost Baron
- */
- class Tx_Crssearch_Service_FileUploadService implements t3lib_Singleton {
- /**
- *
- * @param string $path Pfad zur hochgeladenen Datei
- * @param string $name Ursprünglicher Name der hochgeladenen Datei
- * @return string Pfad zur hochgeladenen Datei im upload-Verzeichnis
- */
- public function moveUpload($path, $name) {
- if (!isset($path)) {
- return null;
- }
- // TODO: Uploadverzeichnis setzen
- $uploadFolder = t3lib_div::getFileAbsFileName('uploads/tx_extkey');
- $basicFileFunctions = t3lib_div::makeInstance('t3lib_basicFileFunctions');
- $name = $basicFileFunctions->cleanFileName($name);
- // Neuer Name der hochgeladenen Datei
- $fileName = $basicFileFunctions->getUniqueName(
- $name,
- $uploadFolder);
- t3lib_div::upload_copy_move(
- $path,
- $fileName);
- // Berechne relativen Pfad zum Wurzelverzeichnis
- $fileName = t3lib_Utility_Path::getRelativePath(PATH_site, $fileName);
- // t3lib_Utility_Path::getRelativePath fügt einen abschließenden Slash
- // hinzu, der muss bei Dateien entfernt werden.
- $fileName = substr($fileName, 0, strlen($fileName)-1);
- return $fileName;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment