/** * you pass this function the key for the $_FILES[key] array * and the new filepath to move the file to * then add the new filename * if $createPath is true then this will attempt to create the directories required for the path * * @param string $key * @param string $path * @param string $filename * @param bool $createPath */ public function upload($key, $path, $filename = false, $createPath = true, $permissions = '777') { if (self::isUploaded($key)) { //default to the name on the client machine if (!$filename) { $filename = $_FILES[$key]['name']; } $path = Digitalus_Toolbox_String::stripLeading('/', $path); if ($createPath) { //attempt to create the new path Digitalus_Filesystem_Dir::makeRecursive(self::PATH_TO_FILES, $path); } //clean the filename $filename = Digitalus_Filesystem_File::cleanFilename($filename); $filename = Digitalus_Toolbox_String::getSelfFromPath($filename); $fullPath = self::PATH_TO_FILES . "/" . $path . "/" . $filename; if (move_uploaded_file($_FILES[$key]['tmp_name'], $fullPath)) { // Set permissions for this file @chmod($fullPath, $permissions); //return the filepath if things worked out //this is relative to the site root as this is the format that will be required for links and what not $fullPath = Digitalus_Toolbox_String::stripLeading('./', $fullPath); return $fullPath; } } }
public static function getCurrentPageName($onlyLast = true) { $uri = new Digitalus_Uri(); $uriString = $uri->toString(); if (true === $onlyLast) { return Digitalus_Toolbox_String::getSelfFromPath($uriString); } return Digitalus_Toolbox_String::stripLeading('/', $uriString); }