Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Image Uploading Problem

Quote Reply
Image Uploading Problem
Hello,

I've seen some previous threads in the past concerning image uploading and I have tried to follow Andy's instructions on how to setup this system, but unfortunately running in a variety of problems.

Here is some background information to help troubleshoot:

Trying to setup so that when a user adds a link, they have the option to append a pic.

Here is where I am at:

1) Implemented from the GL usermanual, a column named IMAGES that parses no spaces etc.
2) Setup the detailed.html template
3) Set the template global to include this programming made by Andy

sub {
# -------------------------------------------------------------------
# This subroutine will get called whenever a tag is called in the templates.
# It will grab the URL to the image...and return it
# Call with <%GetImageURL($ID,FieldName)%>

my ($ID,$field) = @_;

# make sure a fieldname and ID are provided...
if (!$ID || !$field) { return "You need to define the ID and fieldname. Example: &lt\;%GetImageURL(\$ID,'FieldName')%&gt\;"; }

# get the actual path to where the file is/will be saved...
my $schema = $DB->table('Links')->cols;
my $path = $schema->{$field}->{'file_save_url'};
$path =~ s,/$,,; # get rid of trailing / at end of $path

# now we have the highest ID, lets get the image stuff for this link.
my $col = $field; # column name where file is held
my $tbl = $DB->table( 'Links' );
my $fh = $tbl->file_info( $col, $ID ); # return a glob reference to the file that you can print <$fh> if you want
my $rel_path = $fh->File_URL;
undef $fh; # explicit close of the filehandle for good measure

$rel_path =~ s|([^\/]+)$|GT::CGI->escape( $1 )|e;

return $rel_path;

}

I make the call like this in my detailed page:

The location of the file is: <%GetImageURL($ID,'IMAGES')%><br />

But unfortunately, the outcome is this:
The location of the file is: http://www.publicautomotives.com/public/images/u_img//5/5-test.jpg

So, the first problem is that there is an extra '/' after the u-img/ call.

The second problem that I am running into is that if I use the global, getimageurl, and rebuild the database. An error occurs during the compiliation for the
File_URL method call from the global script.

Any suggestions?

Also, has anyone out there successfully implemented the standard image upload feature and display for their gossamer links website? If so, what's the URL?

Thanks in advance,
Raymond Cheung

[/code]