function _services_file_check_destination in Services 7.3
Sanitizes a user-input file path, name and extension.
Parameters
string $destination: The file path, name and extension. The path is optional. Exclude the scheme.
Return value
string A safe file path, name and extension.
2 calls to _services_file_check_destination()
- _file_resource_create in resources/
file_resource.inc - Adds a new file and returns the fid.
- _services_file_check_destination_uri in resources/
file_resource.inc - Sanitizes a user-input file URI.
File
- resources/
file_resource.inc, line 436 - File resource.
Code
function _services_file_check_destination($destination) {
// Split the path by directory separators for both windows and unix.
$directories = preg_split('![\\/]+!', trim($destination));
// Sanitize the filename.
$name = _services_file_check_name_extension(array_pop($directories));
// Sanitize the names of each directory.
$directories = array_filter(array_map('_services_file_check_name', $directories), 'strlen');
// Join the directory and file names back together.
$directories[] = $name;
return implode(DIRECTORY_SEPARATOR, $directories);
}