Function __global->get_url
Definitions
sources/uploads.php
- Get URLs generated according to the specified information. It can also generate a thumbnail if required. It first tries attached upload, then URL, then fails.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: array
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $specify_name | ID_TEXT | No | No | required parameter | N/A | N/A | The name of the POST parameter storing the URL (if '', then no POST parameter). Parameter value may be blank. |
| $attach_name | ID_TEXT | No | No | required parameter | N/A | N/A | The name of the HTTP file parameter storing the upload (if '', then no HTTP file parameter). No file necessarily is uploaded under this. |
| $upload_folder | ID_TEXT | No | No | required parameter | N/A | N/A | The folder name where we will put this upload |
| $obfuscate | integer | No | No | 0 | N/A | N/A | Whether to obfuscate file names so the URLs can not be guessed/derived (a OBFUSCATE_* constant) |
| $enforce_type | integer | No | No | 15 | N/A | N/A | The type of upload it is (bitmask, from CMS_UPLOAD_* constants) |
| $make_thumbnail | boolean | No | No | False | N/A | N/A | Make a thumbnail (this only makes sense, if it is an image) |
| $thumb_specify_name | ID_TEXT | No | No | Blank (empty string) | N/A | N/A | The name of the POST parameter storing the thumb URL. As before |
| $thumb_attach_name | ID_TEXT | No | No | Blank (empty string) | N/A | N/A | The name of the HTTP file parameter storing the thumb upload. As before |
| $copy_to_server | boolean | No | No | False | N/A | N/A | Whether to copy a URL (if a URL) to the server, and return a local reference |
| $accept_errors | boolean | No | No | False | N/A | N/A | Whether to accept upload errors |
| $should_get_something | boolean | No | No | False | N/A | N/A | Whether to give a (deferred?) error if no file was given at all |
| $only_make_smaller | boolean | No | No | False | N/A | N/A | Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images) |
| $member_id | ?MEMBER | No | No | Null | N/A | N/A | Member ID to run permissions with (null: current member) |
| $upload_folder_full | ?PATH | No | No | Null | N/A | N/A | Full path to upload folder, in case it is not relative to the base directory (null: work out) |
| $thumb_folder_full | ?PATH | No | No | Null | N/A | N/A | Full path to thumb folder, in case it is not relative to the base directory (null: work out) |
| $filename | ?string | No | No | Null | N/A | N/A | Filename to use (null: choose one) |
Returns
- An array of 4 URL bits (URL, thumb URL, URL original filename, thumb original filename)
- Type: array
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Get URLs generated according to the specified information. It can also generate a thumbnail if required. It first tries attached upload, then URL, then fails.
*
* @param ID_TEXT $specify_name The name of the POST parameter storing the URL (if '', then no POST parameter). Parameter value may be blank.
* @param ID_TEXT $attach_name The name of the HTTP file parameter storing the upload (if '', then no HTTP file parameter). No file necessarily is uploaded under this.
* @param ID_TEXT $upload_folder The folder name where we will put this upload
* @param integer $obfuscate Whether to obfuscate file names so the URLs can not be guessed/derived (a OBFUSCATE_* constant)
* @param integer $enforce_type The type of upload it is (bitmask, from CMS_UPLOAD_* constants)
* @param boolean $make_thumbnail Make a thumbnail (this only makes sense, if it is an image)
* @param ID_TEXT $thumb_specify_name The name of the POST parameter storing the thumb URL. As before
* @param ID_TEXT $thumb_attach_name The name of the HTTP file parameter storing the thumb upload. As before
* @param boolean $copy_to_server Whether to copy a URL (if a URL) to the server, and return a local reference
* @param boolean $accept_errors Whether to accept upload errors
* @param boolean $should_get_something Whether to give a (deferred?) error if no file was given at all
* @param boolean $only_make_smaller Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images)
* @param ?MEMBER $member_id Member ID to run permissions with (null: current member)
* @param ?PATH $upload_folder_full Full path to upload folder, in case it is not relative to the base directory (null: work out)
* @param ?PATH $thumb_folder_full Full path to thumb folder, in case it is not relative to the base directory (null: work out)
* @param ?string $filename Filename to use (null: choose one)
* @return array An array of 4 URL bits (URL, thumb URL, URL original filename, thumb original filename)
*/
function get_url(string $specify_name, string $attach_name, string $upload_folder, int $obfuscate = 0, int $enforce_type = 15, bool $make_thumbnail = false, string $thumb_specify_name = '', string $thumb_attach_name = '', bool $copy_to_server = false, bool $accept_errors = false, bool $should_get_something = false, bool $only_make_smaller = false, ?int $member_id = null, ?string $upload_folder_full = null, ?string $thumb_folder_full = null, ?string $filename = null) : array
* Get URLs generated according to the specified information. It can also generate a thumbnail if required. It first tries attached upload, then URL, then fails.
*
* @param ID_TEXT $specify_name The name of the POST parameter storing the URL (if '', then no POST parameter). Parameter value may be blank.
* @param ID_TEXT $attach_name The name of the HTTP file parameter storing the upload (if '', then no HTTP file parameter). No file necessarily is uploaded under this.
* @param ID_TEXT $upload_folder The folder name where we will put this upload
* @param integer $obfuscate Whether to obfuscate file names so the URLs can not be guessed/derived (a OBFUSCATE_* constant)
* @param integer $enforce_type The type of upload it is (bitmask, from CMS_UPLOAD_* constants)
* @param boolean $make_thumbnail Make a thumbnail (this only makes sense, if it is an image)
* @param ID_TEXT $thumb_specify_name The name of the POST parameter storing the thumb URL. As before
* @param ID_TEXT $thumb_attach_name The name of the HTTP file parameter storing the thumb upload. As before
* @param boolean $copy_to_server Whether to copy a URL (if a URL) to the server, and return a local reference
* @param boolean $accept_errors Whether to accept upload errors
* @param boolean $should_get_something Whether to give a (deferred?) error if no file was given at all
* @param boolean $only_make_smaller Whether to apply a 'never make the image bigger' rule for thumbnail creation (would affect very small images)
* @param ?MEMBER $member_id Member ID to run permissions with (null: current member)
* @param ?PATH $upload_folder_full Full path to upload folder, in case it is not relative to the base directory (null: work out)
* @param ?PATH $thumb_folder_full Full path to thumb folder, in case it is not relative to the base directory (null: work out)
* @param ?string $filename Filename to use (null: choose one)
* @return array An array of 4 URL bits (URL, thumb URL, URL original filename, thumb original filename)
*/
function get_url(string $specify_name, string $attach_name, string $upload_folder, int $obfuscate = 0, int $enforce_type = 15, bool $make_thumbnail = false, string $thumb_specify_name = '', string $thumb_attach_name = '', bool $copy_to_server = false, bool $accept_errors = false, bool $should_get_something = false, bool $only_make_smaller = false, ?int $member_id = null, ?string $upload_folder_full = null, ?string $thumb_folder_full = null, ?string $filename = null) : array
