Welcome Guest, Not a member yet? Register   Sign In
Loading Images from MySQL db to view in CI
#11

[eluser]vickel[/eluser]
thanks for coming back with help
@elvicmic: I'm using "headers"; what I know, character set for blob should make no difference; the host is superb.net, very professional. Anyway I'm not using any image url, as i'm uploading directly to the blob.
@ GeoXeo: yes, I tried different sizes, yes 64kb, yes maybe in CI I'm loosing a byte or 2

resuming: the writing works fine ! the reading works fine, too !! BUT ONLY if I use the script OUTSIDE CodeIgniter's framework. The exactly same script in a CI controller function (or as a standalone controller) gives me the problem.
#12

[eluser]GeoXeo[/eluser]
Can you put this in your controller and tell me what you see when you invoke http://your_host/your_controller/image

Code:
function image() {
        $hex_img = "ffd8ffe000104a46494600010101004800480000fffe00134372656174656420776974682047494d50ffdb004300080606070605080707070909080a0c140d0c0b0b0c1912130f141d1a1f1e1d1a1c1c20242e2720222c231c1c2837292c30313434341f27393d38323c2e333432ffdb0043010909090c0b0c180d0d1832211c213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232ffc00011080064006403012200021101031101ffc4001500010100000000000000000000000000000008ffc40014100100000000000000000000000000000000ffc40014010100000000000000000000000000000000ffc40014110100000000000000000000000000000000ffda000c03010002110311003f009fc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ffd9";
        Header("Content-type: image/jpeg");
        echo pack("H*", $hex_img);
    }
#13

[eluser]vickel[/eluser]
just a string: http://my_domain.com/index.php/my_controller/image
#14

[eluser]vickel[/eluser]
if I use my script outside CI, I see the image (black square)
#15

[eluser]GeoXeo[/eluser]
I get the same result (a string) if I comment out the 'echo'


My feeling is that Codeigniter is doing something with the stdout buffer when returning from the controller (this must be due to some configuration you've done)

Put an exit() at the end of the method and you'll see your image
#16

[eluser]vickel[/eluser]
I've done that previously in my CI controller and also tested my working script (outside the CI framwork), the latter works with both the first not at all.

How do we forward that issue to one of the CI/Expression Engine Gurus? Maybe they know about an issue, like config setting for database, or similar... ???
#17

[eluser]GeoXeo[/eluser]
do you mean you don't see any image with following code in a controller ?

Code:
function image() {
        $hex_img = "ffd8ffe000104a46494600010101004800480000fffe00134372656174656420776974682047494d50ffdb004300080606070605080707070909080a0c140d0c0b0b0c1912130f141d1a1f1e1d1a1c1c20242e2720222c231c1c2837292c30313434341f27393d38323c2e333432ffdb0043010909090c0b0c180d0d1832211c213232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232323232ffc00011080064006403012200021101031101ffc4001500010100000000000000000000000000000008ffc40014100100000000000000000000000000000000ffc40014010100000000000000000000000000000000ffc40014110100000000000000000000000000000000ffda000c03010002110311003f009fc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007ffd9";
        Header("Content-type: image/jpeg");
        echo pack("H*", $hex_img);
        
        exit();
    }

If this is the case, there may be an issue ...
#18

[eluser]vickel[/eluser]
Yes I can confirm that, only a string when calling the controller function, black square when I call it from outside CI...
#19

[eluser]vickel[/eluser]
I've done some further testing on another domain on a different server, but from the same hosting service. there it works: http://www.bestsurfcamps.com/index.php/backoffice/image
-strange-
#20

[eluser]vickel[/eluser]
Hi GeoXeo, i found the reason: in my appl/config files, I checked database.php .... for some reason the code of database.php started with an empty space. Like:
Code:
<<this is a simple empty space>>&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------
| DATABASE CONNECTIVITY SETTINGS
| -------------------------------------------------------------------
| ... code continues
*/
?&gt;

once I removed that space, I could see the black image square and my controller works as well....

conclusion1: f..k space Smile stay on earth !
conclusion2: strange that the database connection works for all but the BLOB - have fun CI's to find that out




Theme © iAndrew 2016 - Forum software by © MyBB