function webform_file_url in Webform 6.3
Same name and namespace in other branches
- 5.2 components/file.inc \webform_file_url()
- 6.2 components/file.inc \webform_file_url()
- 7.4 components/file.inc \webform_file_url()
- 7.3 components/file.inc \webform_file_url()
Helper function to create proper URLs for uploaded file.
4 calls to webform_file_url()
- theme_webform_display_file in components/
file.inc - Format the output of text data for this component
- theme_webform_render_file in components/
file.inc - Render a File component.
- _webform_csv_data_file in components/
file.inc - Implements _webform_csv_data_component().
- _webform_table_file in components/
file.inc - Implements _webform_table_component().
File
- components/
file.inc, line 599 - Webform module file component.
Code
function webform_file_url($filepath) {
if (!empty($filepath)) {
$info = pathinfo($filepath);
switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
case FILE_DOWNLOADS_PUBLIC:
$path = $info['dirname'] . '/' . rawurlencode($info['basename']);
break;
case FILE_DOWNLOADS_PRIVATE:
// Private file paths must not be encoded as they are run through url()
// which performs the file encoding.
$path = $info['dirname'] . '/' . $info['basename'];
break;
}
$file_url = file_create_url($path);
}
return isset($file_url) ? $file_url : '';
}