Gossamer Forum
Home : Products : Gossamer Links : Discussions :

image file upload

Quote Reply
image file upload
links makes a new folder (named with a number 0-9). Wht does it stop at '9'? shouldn't it continue with ID number?..How do I fix this?

Thank you for reading this Smile
Quote Reply
Re: [wollyowen] image file upload In reply to
That's OK. This is the way it should be. Wink
Quote Reply
Re: [wollyowen] image file upload In reply to
ok....DUHHH I get it ..Tongue hashed vs simple....what is the global to display hashed images in template?

Thank you for reading this :)
Quote Reply
Re: [wollyowen] image file upload In reply to
The global is as follows (taken from my Thumb_Images plugin);

Code:
sub {
# -------------------------------------------------------------------
# Call with <%global_name($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."; }

# 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 );
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;

}

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] image file upload In reply to
I couldn't get this to work. I pasted it as a glbal. named it 'display_image'. FieldNane is 'Images'. so is the call up not: <%display_images($!D, Images)%> ?

John
Quote Reply
Re: [wollyowen] image file upload In reply to
Not trying to be rude, but did you actually read my post? Unsure

Code:
<%if FieldName%>
<%global_name($ID,'FieldName')%>
<%endif%>

...so yours would look something like;

Code:
<%if Images%>
<%display_images($ID, 'Images')%>
<%endif%>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

Andy: Jan 27, 2004, 2:53 PM
Quote Reply
Re: [Andy] image file upload In reply to
I don't take people's rudeness personally. It has nothing to do with me.

" ' " was included actually. I just ommitted it erroneously in the post.

Unable%20to%20compile%20'display_images':

images have uploaded successfully to their respectiev 0-9 folders.
I don't seee anything wrong with Links_Files table.

Dunna workFrown

I merely copy/pasted your code to globals. everything from "sub --> }". It appears in the globals window on one line including #comments
Quote Reply
Re: [wollyowen] image file upload In reply to
ok..of course its not going to work on one line DUH

however..now i get this

A fatal error has occured:
GT::SQL::File (44775): Reference call 'File_URL' does not refer to a method in GT::SQL::File or an allowed attribute. at /usr/home/....../cgi-bin/ent/admin/GT/SQL/File.pm line 939.

Quote Reply
Re: [wollyowen] image file upload In reply to
Please give the tags I described 3 post above this. I have modified them a bit, as you needed an 'if' statement really around the tags :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] image file upload In reply to
this is what i have now Frown


A fatal error has occured:
Can't use string ("1") as a HASH ref while "strict refs" in use at (eval 37) line 3.

Quote Reply
Re: [wollyowen] image file upload In reply to
For the sake of all the poor souls like me who have a small brain. This is what I got to eventually work :)

sub {
my ($rec) = @_;
my $id = $rec->{ID};
if ($rec->{Image}) {
my $links_db = $DB->table('Links');
my $fh = $links_db->file_info( 'Image', $id );
my $location = $fh->File_RelativePath;
if ($fh->File_Name =~ /\.(jpg|gif)$/) {
return qq~ <img src="/...................../images$location"> ~; } else { return "Invalid file name."; } } else {return "";} }

Thank you for your patience
Quote Reply
Re: [wollyowen] image file upload In reply to
Hi,

Please use this in ur template:

<img src="<%db_cgi_url%>/jump.cgi?ID=<%ID%>&view=YourColumName">

Cheer,

Dai Nguyen
Quote Reply
Re: [Beck] image file upload In reply to
In Reply To:
Hi,

Please use this in ur template:

<img src="<%db_cgi_url%>/jump.cgi?ID=<%ID%>&view=YourColumName">

I wouldn't really recommend that. Think how much processing power each one of those calls per page will take. If you are using static pages, I would seriously consider using the image global, rather than jump.cgi :p

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] image file upload In reply to
Andy,

I'm using this global and there are two weird things that pop up. The first (and to me the most disrupting) is that when I build my pages though the admin web interface, this global gets called, and everything seems to work fine. However, when my cron job builds all my pages at night it returns "global_name is not a code reference" where the image path should be and they all show up as broken images.

The other issue that I've seen, though it hasn't happened for a while, is that is sometimes returns the full path to the image and sometimes just the last part of it. i.e.

http://www.domain.com/images/1/pic.jpg

vs just:

/1/pic.jpg

Any thoughts?

Safe swoops
Sangiro
Quote Reply
Re: [sangiro] image file upload In reply to
Hi. I'm not sure what the first problem is (have you tried my Thumb_Images plugin? You have a simple global;

<%Plugins::Thumb_Images::FullURL($ID,'Image1')%>

Regarding the second problem... have you applied the GT::SQL::File bug fix? The best way to find this fix, is to search for "yogi", and enter GT::SQL::File as the search word Smile

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!