Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Re: [Robert] file extention global

Quote Reply
Re: [Robert] file extention global In reply to
Hi Robert,

The file_info() method is what you are looking for. You want to use GT::SQL::File for this (you can read the docs under the Developers Guide). You could do:

Code:
sub {
my $tags = shift;
my $links_db = $DB->table('Links');
my $fh = $links_db->file_info( 'UploadColumn', $tags->{ID} );

# $fh is a file handle that you can read from to access the file, as well as get
# following information:
#
# $fh->File_Name the basic filename
# $fh->File_Directory path to the file
# $fh->File_MimeType mimetype of the file
# $fh->File_Size size of the file
# $fh->File_RelativePath the permuted file and directory without root
#

my $location = $fh->File_RelativePath;
if ($fh->File_Name =~ /\.(jpg|gif)$/) {
return qq~ <img src="/images/imgup/$location"> ~;
}
else {
return "Invalid file name.";
}
}


This isn't tested, but looks like it should work. =)

Cheers,

Alex
--
Gossamer Threads Inc.
Subject Author Views Date
Thread file extention global ridesworld 8729 Sep 8, 2001, 11:52 AM
Thread Re: file extention global
Alex 8544 Sep 10, 2001, 1:28 PM
Thread Re: [Alex] file extention global
Robert 8499 Feb 12, 2002, 2:07 AM
Thread Re: [Robert] file extention global
Robert 8454 Feb 12, 2002, 3:14 AM
Thread Re: [Robert] file extention global
Robert 8493 Feb 12, 2002, 3:19 AM
Thread Re: [Robert] file extention global
Paul 8492 Feb 12, 2002, 3:32 AM
Thread Re: [RedRum] file extention global
Robert 8551 Feb 12, 2002, 7:47 AM
Thread Re: [Robert] file extention global
Robert 8494 Feb 12, 2002, 7:52 AM
Post Re: [Robert] file extention global
Andy 8464 Feb 12, 2002, 8:37 AM
Post Re: [Robert] file extention global
Paul 8475 Feb 12, 2002, 8:44 AM
Thread Re: [Robert] file extention global
Alex 8449 Feb 12, 2002, 1:42 PM
Thread Re: [Alex] file extention global
Robert 8481 Feb 12, 2002, 4:52 PM
Thread Re: [Robert] file extention global
Alex 8459 Feb 12, 2002, 4:54 PM
Thread Re: [Alex] file extention global
Robert 8419 Feb 12, 2002, 10:31 PM
Thread Re: [Robert] file extention global
Robert 8442 Feb 15, 2002, 3:50 AM
Post Re: [Robert] file extention global
courierb 8011 May 2, 2003, 7:22 AM