Jump to content

Display image with sessionid name


Recommended Posts

I'm trying to adapt one thing to prestashop but currently i'm out of luck. I'm using plupload plugin to upload images and then rename file name to session_id.jpg (e.x 34lkjdflkjfdl345fd.jpg )

Upload and rename parts works fine as it's upload file to sitename.com/tmpfile/******.JPG

But the question is - how can i display uploaded picture in prestashop? Since you can't use something like this in .TPL file.


$fileimg = "default/default-logo.jpg";
$fileimg2 = './tmpfile/' . session_id() .'.jpg';


<img src="<?php 
If (file_exists($fileimg2)) {
echo $fileimg2;
} else {
echo $fileimg;
}
?>" alt="Face">

Thanks.

Edited by VladimirKon (see edit history)
Link to comment
Share on other sites

Hi,

 

in the controller or hook function which will render the template where you want the picture appears, you have to assign the session id to smarty: 

$this->context->smarty->assign('my_session_id', session_id());

then in your template, you can put something like 

<img src="{$base_dir}tmpfile/{$my_session_id}.jpg" />
Edited by fred-vinapresta (see edit history)
  • Like 1
Link to comment
Share on other sites

 

Hi,

 

in the controller or hook function which will render the template where you want the picture appears, you have to assign the session id to smarty: 

$this->context->smarty->assign('my_session_id', session_id());

then in your template, you can put something like 

<img src="{$base_dir}tmpfile/{$my_session_id}.jpg" />

Thanks you so much! This is what i was looking for:)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...