Welcome Guest, Not a member yet? Register   Sign In
CI instance object and use of an external library (generation of a pdf)
#1

[eluser]bastien31[/eluser]
Hi,

I will try to be as clear as possible to explain my problem. If not, tell me !

In my app, I did a controller in order to show images uploaded by the users. By this way, the images can only be seen by members and are not public like in facebook for example (image addresses are just hashed but are public).

I also use the mpdf library to generate a pdf from the content of web page. To use it, I have in the third party directory the mpdf library. To be able to use it with my formatting, I put in the libraryn my mpdf library. So the process is : in the pdf controller, I call a function of my mpdf library which create a mpdf object and generate the pdf (using the mpdf in the third party dir.).

So, it works great. But the problem is as following : if I have an image in my page, it's like that :

<img src="http://localhost/www/myapp/library/image/hashed_name_of_the_image" alt="" />

In the image function of the library controller, if i have no restriction, it works and images is shown in the pdf.

But for example, if I put: if($this->session->userdata('logged') == true)

it doesn't !

I understand that the mpdf object which demand the access to the library image function has not a valid session to do it. So I try to use config parameter or to put another type of parameteres but nothing works.

Is there a way to do what I want to do ??? Smile

thanks
Bastien
#2

[eluser]Aken[/eluser]
I'd suggest fetching the actual image file in the same way you do the image in your controller. Why go through all the extra steps in your controller when you can fetch the actual image on your server with less effort? That way there's no need to avoid any session checks in the image controller.

Create a model or library or something to help you, so you don't repeat the same code in your image and PDF controllers.




Theme © iAndrew 2016 - Forum software by © MyBB