mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-01 20:34:20 +01:00
allow to specify a subdirectory in attach_file as part of $file[name] parameter
This commit is contained in:
parent
50270c0994
commit
c17d98ff8c
@ -1166,15 +1166,24 @@ class Link extends Link\Storage
|
|||||||
* @param string $app appname to linke the file to
|
* @param string $app appname to linke the file to
|
||||||
* @param string $id id in $app
|
* @param string $id id in $app
|
||||||
* @param array $file informations about the file in format of the etemplate file-type
|
* @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['type'] mine-type of the file
|
||||||
* $file['tmp_name'] name of the uploaded file (incl. directory) or resource of opened 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
|
* @param string $comment ='' comment to add to the link
|
||||||
* @return int negative id of egw_sqlfs table as negative link-id's are for vfs attachments
|
* @return int negative id of egw_sqlfs table as negative link-id's are for vfs attachments
|
||||||
*/
|
*/
|
||||||
static function attach_file($app,$id,$file,$comment='')
|
static function attach_file($app,$id,$file,$comment='')
|
||||||
|
{
|
||||||
|
// 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);
|
$entry_dir = self::vfs_path($app,$id);
|
||||||
|
}
|
||||||
if (self::DEBUG)
|
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";
|
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