Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Image uploads filing incorrectly in v2.1

(Page 1 of 3)
> >
Quote Reply
Image uploads filing incorrectly in v2.1
I've got 4 picture upload fields for each link using the simple method. I've set the files to be uploaded to a directory, and everything works ok getting there, but the picture is automatically renumbered and it's not matching up with the field ID.

My first field is 'Portrait' and if the user adds a new picture, or if it's added through the admin, it works ok. In the images directory, it might show '9-picture.jpg', but when I go to the detailed page, it shows a missing image. Source shows it should be '1-picture.jpg' instead.

It seems like the images uploaded continue to increase by 1, but the output field doesn't match.

Is there another step involved that I'm missing?

btw...Thanks to those who helped me with my last couple questions!
Perl Hopefull
Quote Reply
Re: [stilton] Image uploads filing incorrectly in v2.1 In reply to
I face same problem too ... please help
Quote Reply
Re: [stilton] Image uploads filing incorrectly in v2.1 In reply to
Hi,

The image upload field does not match the Link ID, as you can have multiple columns (i.e what if Link number 38 had two files both named foo.txt -- you'd end up overwriting each other).

To access the file name, you can use a global such as:

file_name => 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();
}

and then do:

<img src="/images/<%file_name%>">

or something similiar.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
Hi Alex,

Thanks for your help! I added the sub into my template globals as 'Portrait' and it worked perfectly. I then added three more as 'Portrait2','Portrait3','Portrait4' and then used the same sub for each of them. A link has up to 4 pictures they can submit for show in their detail page.

The first image continued to show fine, but the other three are still not being displayed properly. Is their another step I need to make in order for multiple images to be uploaded and linked to?

Thanks again for the help,

Steve
Perl Hopefull
Quote Reply
Re: [stilton] Image uploads filing incorrectly in v2.1 In reply to
I *think* what you may be doing is trying to use the subroutine of the globals as a function, and that doesn't work, at least in the simple manner.

You would have to have one subroutine for each image field:

file_name1 => sub {...}
file_name2 => sub {...}

etc.

You would use a modified sub, referencing the appropriate field, then use <%file_name1%> where you want that to show up, <%file_nam2%> for that, etc.

I'm not sure you can pass arguments to template globals, but you could make this a function, and use the same sub routine for all fields, just passing in the one you want.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Image uploads filing incorrectly in v2.1 In reply to
Hi Pugdog,

Hopefully I'm doing what Alex has given correctly....I hope Crazy I've taken the following codes and placed them in the template globals:

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();
}


and then placed <img src="/images/<%Portrait%>"> where the graphic should go. I then created three other identical subroutines in my template globals, but used a new name for each one such as 'Portrait2' and so on...

I didn't see anything in the codes that would need to be altered with the exception of the names. Shouldn't this work this way?

Thanks again,

Steve
Perl Hopefull
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
I was a little early in concluding all was well. The pictures are not in the same sequence of numbering for some reason. They upload to the proper folder, but the numbering is still off, but there seems to be a pattern. I'm using Link ID #4 right now with 4 image upload fields for each link:

I upload image1.jpg for <%Portrait%> and it is received as 13-image1.jpg but is called by the detailed page as 4-image1.jpg

I upload image2.jpg for <%Portrait2%> and it is received as 17-image2.jpg but is called by the detailed page as 4-image2.jpg

I upload image3.jpg for <%Portrait3%> and it is received as 15-image3.jpg but is called by the detailed page as 4-image3.jpg

I upload image4.jpg for <%Portrait4%> and it is received as 16-image4.jpg but is called by the detailed page as 4-image4.jpg

If I modify the profile and change <%Portrait4%> by uploading a new image, it uploads newimage4.jpg as 16-newimage4.jpg but is called by the detailed page as 4-newimage4.jpg

I'm using the subroutine you gave me like this in the Template Globals:

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();
}

Each image field is titled as Portrait, Portrait2, Portrait3, Portrait4 with the same sub above.

I then call each image on the templates as
<img src="http://www.mysite.org/images/members/<%Portrait%>"> Making sure that I have each Portrait linked appropriately, not all like this one!

I hope I was able to explain a little better with this example. The detail page wants to use the link ID, but the upload feature isn't in sync with it.
Perl Hopefull
Quote Reply
Re: [stilton] Image uploads filing incorrectly in v2.1 In reply to
Hi,

Try this, it should be simpler.

Add a global called image_name =>

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

and then in your link.html template you can put:

<img src="/images/<%image_name('Portrait',$ID)%>">
<img src="/images/<%image_name('Portrait2',$ID)%>">
<img src="/images/<%image_name('Portrait3',$ID)%>">
<img src="/images/<%image_name('Portrait4',$ID)%>">

This assumes your four columns are name Portrait, Portrait2, Portrait3, Portrait4.

Hope that helps,

Alex
--
Gossamer Threads Inc.

Last edited by:

Alex: Feb 27, 2002, 4:42 PM
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
Thanks Alex for the quick response. I added the subroutine to the globals and added the codes in the detailed.html template. I then uploaded new pictures and went to build, but got the following fatal error:

A fatal error has occured:
GT::SQL::File (32521): Reference call 'Relative_Name' does not refer to a method in GT::SQL::File or an allowed attribute. at GT::Base::_format_err line 5.


I enabled debugging, but didn't do to well trying to decipher what it was I was looking at.

Steve

Perl Hopefull
Quote Reply
Re: [stilton] Image uploads filing incorrectly in v2.1 In reply to
Oops, I edited it, try it again.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
Perfect!!! I actually did try to change the ->Relative_Name; in the original post to several different combinations before that last message....apparantly not the right one though.

Thanks a lot for all of your help! I'm really beginning to see how much more flexible Links SQL really is.

Steve
Perl Hopefull
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
So you *can* pass parameters to the template globals :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Image uploads filing incorrectly in v2.1 In reply to
New to 2.1.0. =)

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
Alex, I just implemented the solution you provided but it is not displaying the images on the page. This is what displays instead of the image:

SN95.COM new
Once upon a time there was a website!
http://www.sn95.com




I added the "Image_name" global variable as you suggested:

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

I then added the following code to the link.html template to display the image:

<%if Imagefile%>
<br>
<img src="/images/<%image_name('Imagefile',$ID)%>">
<br>
<br>
<%endif%>


Would appreciate any assistance you can provide.

Scott Halliday
Scott Halliday
Quote Reply
Re: [shalliday] Image uploads filing incorrectly in v2.1 In reply to
The image is displaying 'http://216.12.214.210/images//3-RobAvatar.gif'. Is this the right URL?

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
There's a double slash in there too :)
Quote Reply
Re: [shalliday] Image uploads filing incorrectly in v2.1 In reply to
Scott, found the error, a little typo, but we have another problem, theres no "images" subdir, all files are going into "var/www".
Quote Reply
Re: [Rob Hernandez] Image uploads filing incorrectly in v2.1 In reply to
Hi,

You can control what path the images are placed in by editing the Image column (you can do this in Database->Links->Properties and then click on the column).

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
I get this error:

A fatal error has occured:
Can't call method "File_RelativePath" on an undefined value at (eval 33) line 3.
Please enable debugging in setup for more details.


I use the following global which I called image_name

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

Within link.html I use:

<%if Image%>
<img src="/images/<%image_name('Image',$ID)%>" width="150"><br>
<%endif%>

The image column has the name Image







--
Michael Skaide

http://www.cycle24.de

Quote Reply
Re: [Sir Up] Image uploads filing incorrectly in v2.1 In reply to
Finally, i am here. unfortunately i got the same error.
may be the code is ok for 2.1

i am using version 2.11.

how to correct it?

Thanks
Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
Sorry. i have do a resh installation and it works now
Quote Reply
Re: [Sir Up] Image uploads filing incorrectly in v2.1 In reply to
Hi,

I also get the following error with 2.1.2:

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


using this code as global:

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


Image Upload via Admin works fine - just to show it in the Detailed template does not work for me.

Lars
Quote Reply
Re: [calliope] Image uploads filing incorrectly in v2.1 In reply to
Hi,

You are using:

<%if Image%>
<img src="/images/<%image_name('Image',$ID)%>" width="150"><br>
<%endif%>


in your code, right? If no Image exists, you _will_ get an error.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Image uploads filing incorrectly in v2.1 In reply to
Thanks for your reply.

I simply made a small mistake in naming the column...

And I just found another mistake:
I had to add the base directory to the path:
<img src="/finder/images/clients<%Logo_Clients('Logo_Client',$ID)%>">

Now it works fine!


Thanks,
Lars
Quote Reply
Re: [calliope] Image uploads filing incorrectly in v2.1 In reply to
Just FYI, you can also use jump.cgi as a method to show images. Something like;

<img src="jump.cgi?source=fieldname&ID=<%ID%>">

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!
> >