Skip to content

Commit

Permalink
Add uploadPath() and uploadUrl() methods
Browse files Browse the repository at this point in the history
Closes #39

Build path and URL for uploaded files using naming standards.
  • Loading branch information
geekwright committed Oct 9, 2019
1 parent e8e176e commit 3a75918
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Module/Helper/GenericHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,38 @@ public function redirect($url, $time = 3, $message = '')
{
redirect_header($this->url($url), $time, $message);
}

/**
* Return absolute URL for a module relative upload file
*
* Uploads may be stored in special directories for many reasons,
* such as permissions, security, replication and directory balancing
* Rather than build their own URL's, modules should use this method
* which will know how to reference the upload now and in the future.
*
* @param string $url module relative upload URL
*
* @return string
*/
public function uploadUrl($url = '')
{
return XOOPS_UPLOAD_URL . '/' . $this->dirname . '/' . $url;
}

/**
* Return absolute filesystem path for a module relative upload file
*
* Uploads may be stored in special directories for many reasons,
* such as permissions, security, replication and directory balancing
* Rather than build their own URL's, modules should use this method
* which will know how to reference the upload now and in the future.
*
* @param string $path module relative upload file path
*
* @return string
*/
public function uploadPath($path = '')
{
return XOOPS_UPLOAD_PATH . '/' . $this->dirname . '/' . $path;
}
}

0 comments on commit 3a75918

Please sign in to comment.