• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to send an image to a specific part of website?

#1
Smile 
Hi sir/ma'am, I wanna ask how can I do this on CodeIgniter, where I can upload an image then after that it will display on the sidebar. Let's say I had may dropdown for locations for that specific image before to upload and when select location (e.g homepage sidebar) and finish uploading then it will display on homepage sidebar  Confused thank you so much for the help !
Reply

#2
You would need to save the image name and path to the database then do
a redirect back to the page with a refresh.

You would also need a method in the controller for loading the sidebar images
from the database.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
Thank you sir, but how can I send that image to that specific position on the website? should I make div tags with ID's and echo the image path redirect on that div tags? sorry sir, I cant execute it properly.
Reply

#4
You can do it something like this its just an example:

PHP Code:
// -----------------------------------------------------------------------

/**
 * htmlImage
 * 
 * Place in a CI Helper
 * 
 * TODO: Add Eror Handling...
 */
if ( ! function_exists('htmlImage'))
{
 
   /**
     * htmlImage ()
     * -------------------------------------------------------------------
     *
     * $image = assign the database image path and name here
     * IE: http://www.yoursite.com/assets/images/image01.png
     * 
     * $alt   = 'Alt Image Name';
     * 
     * $data['image'] = htmlImage($image, $alt);
     * 
     * You can now access the image in the html view
     * 
     * <?php echo $image; ?>
     * 
     * @param  string $image
     * @param  string $alt
     * @return string
     */
    
function htmlImage(string $image ''string $alt '') : string
    
{
     
   $out '';

 
       $out .= '<img src="'.$image.'" alt="'.$alt.'" />';

        return 
$out;
    }


Read the comments.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#5
(02-07-2018, 03:56 AM)InsiteFX Wrote: You would need to save the image name and path to the database then do
a redirect back to the page with a refresh.

You would also need a method in the controller for loading the sidebar images
from the database.

(02-07-2018, 10:14 AM)InsiteFX Wrote: You can do it something like this its just an example:

PHP Code:
// -----------------------------------------------------------------------

/**
 * htmlImage
 * 
 * Place in a CI Helper
 * 
 * TODO: Add Eror Handling...
 */
if ( ! function_exists('htmlImage'))
{
 
   /**
     * htmlImage ()
     * -------------------------------------------------------------------
     *
     * $image = assign the database image path and name here
     * IE: http://www.yoursite.com/assets/images/image01.png
     * 
     * $alt   = 'Alt Image Name';
     * 
     * $data['image'] = htmlImage($image, $alt);
     * 
     * You can now access the image in the html view
     * 
     * <?php echo $image; ?>
     * 
     * @param  string $image
     * @param  string $alt
     * @return string
     */
    
function htmlImage(string $image ''string $alt '') : string
    
{
     
   $out '';

 
       $out .= '<img src="'.$image.'" alt="'.$alt.'" />';

        return 
$out;
    }


Read the comments.

Thank you so much sir  Big Grin god bless.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.