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:
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.
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.