How to see image in joomla article (using fileupload element)

javier94

Member
hello,
I'm using fileupload element to save and image, using the user_id and name of the user.

in the fileupload element i save the image as:

/images/stories/{$my->id}-{$my->name}/

so the url image saved is
images/stories/967-marc/image-1.png

till here is ok

Now i try to see this image and a nombre_establecimiento in a joomla article.

I can see the nombre_establecimiento.. but the image is not working

i think that maybe would be because i need to add the user name also.. but i don´t know how to add. so when i make the echo to find the image, the image is not showed.

the code use is

{source}<?php

$user =& JFactory::getUser();
$userId = $user->get( 'id' );

$db = JFactory::getDbo();
$query = $db->getQuery(true);

//echo $userId;

$query->select($db->quoteName(array('nombre_establecimiento', 'user_id','logo_upload')))

->from($db->quoteName('insertar_logo'))

->where($db->quoteName('user_id') . ' = ' . $userId);

$db->setQuery($query);

$results = $db->loadAssocList();

foreach ($results as $rows) {
echo "<center>";
echo "<img src='images/stories/" . $user_id . "/image-1.png'>";
echo "<H1>" . $rows['nombre_establecimiento'] . "</H1>" . "<BR>";
echo "</center>";

}
?>{/source}

Maybe i should add something more, with the name of user to find the image in the "echo image code"

Any suggestion??

thanks in advance

Javier
 
If your image path is images/stories/967-marc/image-1.png
you won't get it with src='images/stories/" . $user_id . "/image-1.png' which will be src='images/stories/967/image-1.png'
You must add the username, too.
 
ok. will change the image path for

/images/stories/{$my->id}/

and the code.. was a mistake in userid --> by userId

{source}<?php

$user =& JFactory::getUser();
$userId = $user->get( 'id' );

$db = JFactory::getDbo();
$query = $db->getQuery(true);

//echo $userId;

$query->select($db->quoteName(array('nombre_establecimiento', 'user_id','logo_upload')))

->from($db->quoteName('insertar_logo'))

->where($db->quoteName('user_id') . ' = ' . $userId);

$db->setQuery($query);

$results = $db->loadAssocList();

foreach ($results as $rows) {
echo "<center>";
echo "<img src='images/stories/" . $userId . "/image-1.png'>";
echo "<H1>" . $rows['nombre_establecimiento'] . "</H1>" . "<BR>";
echo "</center>";

}
?>{/source}

thanks
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top