mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +01:00
allow to specify a subdirectory in attach_file as part of $file[name] parameter
This commit is contained in:
parent
4b2f08f5b7
commit
dbb07961f6
@ -1166,7 +1166,7 @@ class Link extends Link\Storage
|
||||
* @param string $app appname to linke the file to
|
||||
* @param string $id id in $app
|
||||
* @param array $file informations about the file in format of the etemplate file-type
|
||||
* $file['name'] name of the file (no directory)
|
||||
* $file['name'] name of the file (optional incl. a directory)
|
||||
* $file['type'] mine-type of the file
|
||||
* $file['tmp_name'] name of the uploaded file (incl. directory) or resource of opened file
|
||||
* @param string $comment ='' comment to add to the link
|
||||
@ -1174,7 +1174,16 @@ class Link extends Link\Storage
|
||||
*/
|
||||
static function attach_file($app,$id,$file,$comment='')
|
||||
{
|
||||
$entry_dir = self::vfs_path($app,$id);
|
||||
// check if $file['name'] specifies a subdirectory, in which case use and, if necessary, create it
|
||||
if (is_array($file) && strpos($file['name'], '/') && strpos($file['name'], '..') === false)
|
||||
{
|
||||
$entry_dir = self::vfs_path($app, $id, Vfs::dirname($file['name']));
|
||||
$file['name'] = Vfs::basename($file['name']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$entry_dir = self::vfs_path($app,$id);
|
||||
}
|
||||
if (self::DEBUG)
|
||||
{
|
||||
echo "<p>attach_file: app='$app', id='$id', tmp_name='$file[tmp_name]', name='$file[name]', size='$file[size]', type='$file[type]', path='$file[path]', ip='$file[ip]', comment='$comment', entry_dir='$entry_dir'</p>\n";
|
||||
|
Loading…
Reference in New Issue
Block a user