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

Can't call method "File_RelativePath" Picture Error

Quote Reply
Can't call method "File_RelativePath" Picture Error
Hello,

I've switched servers again and now I'm having trouble with uploading pictures. No matter what I seem to try, I get this:

Can't call method "File_RelativePath" on an undefined value at (eval 30) line 3.


In my globals, I'm using this:

sub {
my $tags = shift;
my $file = $DB->table('Links')->file_info('ColumnName', $tags->{ID}) or return "Link ID $tags->{ID} does not have a file attached.";
return $file->File_RelativePath();
}


In the Link Table, I have a column name as MainPic, Form type is File, Save Method is Simple, and the Save Path is an Absolute Path which it does recognize in during the link setup properties. I had this working before, so the codes should work ok still, even on a new server....or so I thought.

Any help on this would be Greatly Appreciated!
Perl Hopefull
Quote Reply
Re: [stilton] Can't call method "File_RelativePath" Picture Error In reply to
Do you need;

return $file->File_RelativePath($tags->{ID});

Crazy Not sure..but its worth a try.

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] Can't call method "File_RelativePath" Picture Error In reply to
Nope, the error is due to $file being undefined.

Last edited by:

Paul: Jun 11, 2002, 2:07 AM
Quote Reply
Re: [Paul] Can't call method "File_RelativePath" Picture Error In reply to
Why would it be undefined suddenly like that? One of the oddities is that you can submit your changes and get the error message, but if I validate changes in the admin, I can see the name of the picture files that were to be uploaded along with any other changes, but the files themselves weren't actually uploaded.

Prior to the server switch, it worked well creating a new folder for each link and labeling them as needed...

Thanks for any help you might be able to share,
Perl Hopefull
Quote Reply
Re: [stilton] Can't call method "File_RelativePath" Picture Error In reply to
It means that the file_info() method (subroutine) isn't returning a reference....a similar example is when you do a select. Take this as an example:

Code:
my $sth = $DB->table('Links')->select( { Foo => 'Bar' } );
my $row = $sth->fetchrow;

This will work because the select() method returns a blessed reference which you can use to call the fetchrow() method ($sth...you can see what I mean by printing $sth).....however if you were to do:

Code:
my $sth = $DB->table('Links')->select( { Foo => 'Bar' } )->fetchrow;
my $row = $sth->fetchrow;

....you would get the error about not being able to call method fetchrow on an undefined value, this is because when the fetchrow() method is compiled the first time after doing the select, the reference is destroyed and nothing is returned. So then when it tries to run $sth->fetchrow, because $sth is undefined the script doesn't know what to do and dies with an error.

I've never used file_info before so I can't give you a solution to your problem but maybe that explanation will help you solve the problem.

Last edited by:

Paul: Jun 11, 2002, 6:17 AM
Quote Reply
Re: [Paul] Can't call method "File_RelativePath" Picture Error In reply to
Thanks for the info, but no luck so far.....here's what I've got:

In Template Globals, I have a global called MainPic with the following routine:

sub {
my $tags = shift;
my $file = $DB->table('Links')->file_info('ColumnName', $tags->{ID}) or return "Link ID $tags->{ID} does not have a file attached.";
return $file->File_RelativePath();
}


In the Include_Form field, I have it setup as such:

<input type="file" name="MainPic" size="20">

In the places I wish the picture to appear, it shows as this:

<%if MainPic%><img src="http://www.website.org/members/pictures/<%image_name('MainPic',$ID)%>"><%endif%>

And in another template global, I have the following for image_name:


sub {
my ($col, $id) = @_;
return $DB->table('Links')->file_info($col,$id)->File_RelativePath;
}




No matter what I try, I continue to receive the same error everytime:

A fatal error has occured:
Can't call method "File_RelativePath" on an undefined value at (eval 30) line 3.




I have MainPic defined in link properties as:

Column Type: CHAR
Column Index: None
Size: 40
Not Null
Form Type: FILE
Size: 40
Location: /home/website/www/members/pictures
Save Method: Simple

What in the world am I doing wrong????? Alex had originally helped me to get this setup and it worked perfectly before.

Thanks again for any input...
Perl Hopefull
Quote Reply
Re: [stilton] Can't call method "File_RelativePath" Picture Error In reply to
I ended up taking a week off and now that I've somewhat relaxed, I'm trying to hit this thing again, but I'm still getting the same errors. Anyone else have any ideas? I found some directories on the server that had changed the permissions when I switched, but I've since restored them to what they should be...particularly where the pictures are to be uploaded.

Any other clues or comments??????

Thanks,
Perl Hopefull
Quote Reply
Re: [stilton] Can't call method "File_RelativePath" Picture Error In reply to
i have got the same problem now.
any one now fix the problem?

i have been look for the solutions for few weeks, but non one here post a clear solution.


Thanks
Quote Reply
Re: [courierb] Can't call method "File_RelativePath" Picture Error In reply to

Integrating Images Into Links SQL Frown



Somebody has a solution for this problem?

Can't call method "File_RelativePath"

Thank you!!

-----------------------
Nomada
Quote Reply
Re: [Nomada] Can't call method "File_RelativePath" Picture Error In reply to
Can you post the actual globals you are using - I think that there are a few more of us know who might be able to help with this.
Quote Reply
Re: [afinlr] Can't call method "File_RelativePath" Picture Error In reply to
Hi afinlr,

I use the http://www.gossamer-threads.com/...i?post=184526#184526 Alex global as "imagen"

Code:

sub {
my ($col, $id) = @_;
return $DB->table('Links')->file_info($col,$id)->File_RelativePath;
}


And I have this into my link.html template:

Code:

<%if Imagen%>
<a href="<%build_root_url%>/imagenes<%imagen('Imagen',$ID)%>">
<img src="<%build_root_url%>/imagenes<%imagen('Imagen',$ID)%>" height="160" border="0">
</a>
<%endif%>


Where Imagen is the name of the column for images files...

OOOOOOOOhhhhhhhh!!!!Blush

WORKS NOW!!!! INCREDIBLE!!!Sly

I have repeat all the steps an works fine.... ju,ju,ju... reggae music for all!!Cool

Thank you for nothing

-----------------------
Nomada
Quote Reply
Re: [Nomada] Can't call method "File_RelativePath" Picture Error In reply to
Laugh Glad its working.
Quote Reply
Re: [Nomada] Can't call method "File_RelativePath" Picture Error In reply to
Does it work with images which contains spaces in their names?

Example: image name.gif
Quote Reply
Re: [Payooo] Can't call method "File_RelativePath" Picture Error In reply to
Why would you have blank spaces in the filename? That's not a correct method of naming files for use on the web. Even if the blank space is exchanged for a %20 encoding, some browsers/systems may have a problem displaying the image. There shouldn't be blank spaces in file names or paths.
Quote Reply
Re: [Karen] Can't call method "File_RelativePath" Picture Error In reply to
In Reply To:
Why would you have blank spaces in the filename? That's not a correct method of naming files for use on the web. Even if the blank space is exchanged for a %20 encoding, some browsers/systems may have a problem displaying the image. There shouldn't be blank spaces in file names or paths.


Hi, I know that, but, what about my users?