Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Image uploads filing incorrectly in v2.1

(Page 2 of 3)
> > > >
Quote Reply
Re: [pugdog] Image uploads filing incorrectly in v2.1 In reply to
Hi Pugdog,

of course you where right.
I had included the reqiured images.
If one of them is missing the code you mention does not work.

For all of tose who try - the following helps:

<%if Image_Client%><img src="<%build_root_url%>/images/clients/<%Image_Clients('Image_Client',$ID)%>"><%else%><img src="<%build_root_url%>/images/default/ClearShim.gif"><%endif%>


where "Image_Client" is the fieldname and "<%build_root_url%>/images/clients/" my base directory for the images of clients.

The export of HTML works fine then.
Quote Reply
Re: [calliope] Image uploads filing incorrectly in v2.1 In reply to
<wagging tail>

I needed a pat on the back today ;)


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
/me pats pugdog on that back Laugh

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: [Alex] Image uploads filing incorrectly in v2.1 In reply to
strange problem again.
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)%>">

when put <%Portrait%> tag in modify_success.html ,

there is no value for <%Portrait%>
here is code i am using. The result always be "NO Pic available"
<%if Portrait%><img src="/img/<%image_name('Portrait2',$ID)%>"><%else%>NO Pic available<%endif%>

While i put tab <%Portrait2%> in link.html and add_success.html, I get the value correly.



What is the real problem. weather i did not using it in a proper way?
Any suggestion would be greatly appreciated.



Thanks
Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
I've had this problem before. It is to do with passing variables into a tag, whilst using an 'if'. For example, this would work;

<%if image_name%>

... but as soon as you put the following part in;

('Portrait',$ID)


... then LSQL doesn't parse it correctly. The way I get around this, is to generate an extra tag. It uses a bit more processing power,but at least it works. Try creating a new global, which can be called at the top of the modify_success.html template....

check_image_status =>

Code:
sub {

my ($col, $id) = @_;
my $check = $DB->table('Links')->file_info($col,$id)->File_RelativePath;

$check ? return { check_image => 1 } ? { check_image => 0 }

}

...then, use something like this to check if it exists;

Code:
<%-- Call the below tag. Although it
doesn't/shouldn't return anything, we need to
run it, so we can get a value for the 'if' stag... --%>
<%check_image_status%>

<%-- check_image will not hold '1' if an image is available... --%>
<%if check_image%>
<img src="/img/<%image_name('Portrait2',$ID)%>">
<%else%>
NO Pic available
<%endif%>


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!
Quote Reply
Re: [Andy] Image uploads filing incorrectly in v2.1 In reply to
Andy.



thanks for your reply.

after a try, i got a error

Unable to compile 'check_image_status':

any idear for this error? what is actaul meaning for
$check ? return { check_image => 1 } ? { check_image => 0 }

as i said in last post. <%Portrait2%> tag is working in link.html ,add_success.html or include_form.html however it is not working proplerly when is inserted in modify_success.html .

The only case i found it is not work is insert tag in modify_success.html . if any difference for proscessing tags in these template?

Many thanks
Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
Sorry, it should be;

Code:
$check ? return { check_image => 1 } : { check_image => 0 };


Basically, what this does, is check to see if $check holds a value. If it does, then it assigns the variable <%check_image%> a value of 1 (TRUE), and if not, then it assigns FALSE.

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 uploads filing incorrectly in v2.1 In reply to
Dear Andy.

I got this error when using your code. I wonder the error comes if no Portrait2 existed.



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


Please enable debugging in setup for more details.

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



Thanks
Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
Odd. How about with this HTML;

Code:
<%-- Call the below tag. Although it
doesn't/shouldn't return anything, we need to
run it, so we can get a value for the 'if' stag... --%>
<%if Portrait2%>
<%check_image_status%>
<%endif%>

<%-- check_image will not hold '1' if an image is available... --%>
<%if check_image%>
<img src="/img/<%image_name('Portrait2',$ID)%>">
<%else%>
NO Pic available
<%endif%>

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: [courierb] Image uploads filing incorrectly in v2.1 In reply to
Hi,

In this situation you need to turn debugging to 1 and you'll get a more informative error message.
Quote Reply
Re: [Andy] Image uploads filing incorrectly in v2.1 In reply to
Quote:
I've had this problem before. It is to do with passing variables into a tag, whilst using an 'if'. For example, this would work;

<%if image_name%>

... but as soon as you put the following part in;

('Portrait',$ID)


... then LSQL doesn't parse it correctly.


Andy,

Do you have more details? I have many globals that pass in 2,3 or more parameters, and have not had a problem with parsing the passed data.

I'm wondering where you are having the problems, or where I've avoided them.


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
Its not a problem directly with passing variables, but more with passing them in an 'if'. ... i,e;

<%if global_name($ID)%>

... it doesn't get the true value, even if the global has something like;

Code:
sub {

$_[0] ? return 1 || return 0;

}

Never been able to get this to work correctly. Not sure if its a bug, or a limitation.

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 uploads filing incorrectly in v2.1 In reply to
Thanks all.



Andy

as i said before, the strange problem is i can not get value of <%Portrait2%> or <%if Portrait%> or <%Portrait3%>

So <%check_image_status%> will not be called in anytime in my case.
<%if Portrait2%>
<%check_image_status%>
<%endif%>



For my case. i used below code originally. If no pic exist. then the

<%if Portrait2%>
<img src="/img/<%image_name('Portrait2',$ID)%>">
<%else%> no pic available
<%endif%>

the result is frustrated me. No error appear while it shows " no pic available" no matter
Portrait2 value exist in db or not. while same code is working in link.html tempalate.
i got what i want result in link.html .( when pic exist, i got a pic printed out, while show
"No pic available " when no pic avaialble in db.


SO the problem is only occoured when using tag in modify_success.html. i have tested in other Template, all works well except in modify_success.html.



just a little bit more infos, when a user modify a link, if he changes Portrait2 value by upload a new image, then problem gone. if a user leave Portrait2 field blank ( no changes to portraits value stored in db), then the problem occoured, When user click "modify" to go to the the next step, the screen returns modify_sucess.html page with NUll value of <%portrait2%>

I serched all forum there is even no report for this issue. I wonder if if anything goes wronly in code in somewhere else.



Thanks





Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
mainly there are two problems

<%file_name%> will return error if no pic exist. ( this is a globle problem)
Can't call method "File_RelativePath" on an undefined value at (eval 47) line 3.
this is mention by Pudong in the this thread before.


<%Portrait%> will not get a correct value only in template modify_success.html

Last edited by:

courierb: Sep 1, 2003, 7:05 PM
Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
Mmm. I wonder if there is way to get rid of the error message shown with GT::SQL . Could you try;


Code:
sub {

my ($col, $id) = @_;

my $sth = $DB->table('Links')->select( { ID => $id } );

my $field;
while (my $hit = $sth->fetchrow_hashref) {
$field = $hit->{$col};
}

my $check = 0;
if ($field) {
$check = $DB->table('Links')->file_info($col,$id)->File_RelativePath;
}

$check ? return { check_image => 1 } ? { check_image => 0 }

}

Does that work?

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 uploads filing incorrectly in v2.1 In reply to
Andy, thanks, i am using your new code and have a test just now.

The result comes out without error message. it print out "NO Pic available " No matter pic is exit in db or not.

this result is similar to using below code.
<%if portrait2%> show pic <%else%>No pic available<%endif%>

Thanks again.
Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
Sorry, does that mean its working or not? (didn't quite understand).

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 uploads filing incorrectly in v2.1 In reply to
Hi,

Passing in an <%IF%> test, may not be a bug, but it is a known limitation. Hopefully it's being worked on. Another programmer and I went a round or two on this about 6 or so months ago. It would be cool to have, but I think it may increase the parser complexity a bit.

*BUT* I read what you said as passing in multiple parameters to a global, and that works fine :) -- as long as it's not inside an <%if%> test.

The only way to get around it is to use the <%set %> notation, or pass back another global result, or do the test in a global, rather than in the template.

<%function_evaluate_test_return_1_or_0($a, $b,...$)%>
<%if function_evaluate_test_result%> ..... <%endif%>

I have these sort of statements littered through my templates, and sort of do it by habit now. Once it's fixed up <G> I'll probably still do it <G>


PUGDOG� Enterprises, Inc.

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

The error message is not occour. however it did not shows the result expected

in other words, there is no value passed to the tag. so it always shows "no pic avaiable"

even the pic is actually exist on the db.



This is quite similar with puting a tag <%Portrait%> in modify_sucessful.html. no matter actual value in db. There is no value passed to tag <%Portrait%>. while other tags are working well in modify_sucessful.html template. <%Portrait%> tag also working well in other template, excpet not working properly in modify_sucessful.html



Thanks
Quote Reply
Re: [courierb] Image uploads filing incorrectly in v2.1 In reply to
I'm afraid I'm stuck then .. sorry Frown

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: [pugdog] Image uploads filing incorrectly in v2.1 In reply to
Code:
<%function_evaluate_test_return_1_or_0($a, $b,...$)%>
<%if function_evaluate_test_result%> ..... <%endif%>

Yeah, I've been doing this recently (mainly with my Overture plugin) .. I call the tag at the top of the page, and then to see if a result was found (for page fomatting), I do something like;

<%if overture_check2%>
... do this...
<%endif%>

Also, you are right.. the <%set field = 'value'%> is a good idea, as long as you only need to set a specific value, and not get a retuned value.

Thanks for your time on this pugdog...

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 uploads filing incorrectly in v2.1 In reply to
Andy i am sorry to take you so many times. it seesm that i may be the bug . i put <%GT::Template::dump%> in it. and find t here is no value in any newly added image tag
<%protrait%>. and this only happened in add_sucessful.html template.

I will address to alex to see if it has a easy fix in this version.



Thanks.
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
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



This won't work with images with blank spaces in their names. (Blank space is replaced with %20) Frown
Suggestions?
Quote Reply
Re: [Payooo] Image uploads filing incorrectly in v2.1 In reply to
Could try:

my $path = $DB->table('Links')->file_info($col,$id)->File_RelativePath;
return \$path;

This will ensure it's not html escaped.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Image uploads filing incorrectly in v2.1 In reply to
Thanks Alex, but it doesn't work Crazy


Maybe I should clear some things;

during the upload (via admin), the spaces are converted to %20's.

So, "image one.gif" is now "image%20one.gif".

Images are uploaded, but I cant open them even by typing their URL.


If I upload image with space in name with FTP I can open it.

Thanks!
> > > >