Welcome Guest, Not a member yet? Register   Sign In
Help with Output image
#11

[eluser]toopay[/eluser]
Code:
$imagepath = str_replace(chr(92),'/',$_SERVER["DOCUMENT_ROOT"]).'/test/'.$imagepath;

As you can see, the problems is you are try to access invalid file, thats why it generates errors. Work around with above code.
#12

[eluser]SoulM4n[/eluser]
[quote author="toopay" date="1304709044"]
Code:
$imagepath = str_replace(chr(92),'/',$_SERVER["DOCUMENT_ROOT"]).'/test/'.$imagepath;
[/quote]

yes sorry .. here is the code i have :

Code:
public function showpic()
    {
        $idpic = $this->uri->segment(3);
        $this->db->where('id',$idpic);
        foreach($this->db->get('account_gallery')->result() as $row)
        {
            $photo = $row->thumb;    
        }        
        $imagepath = 'test/gallery/'.$this->session->userdata('nickname').'/thumbs/'.$photo;
        $imagepath = str_replace(chr(92),'/',$_SERVER["DOCUMENT_ROOT"]).'/'.$imagepath;
        //var_dump($imagepath); exit;

        if (file_exists($imagepath))
        {
            $this->output->set_content_type('jpeg');
            $this->output->set_header('Content-Type: image/jpeg');
            $this->output->set_output(file_get_contents($imagepath));
        }
        else
        {
           echo 'Invalid image path';
        }    
    }


and it doesn't work .. here is the path i get :

Code:
string(67) "C:/inetpub/wwwroot/test/gallery/nick/thumbs/_MAG0921_thumb.jpg"

And with this path i get no image and no errors
#13

[eluser]toopay[/eluser]
What if you put that path directly into your browser? Is that generates the right image?
#14

[eluser]SoulM4n[/eluser]
[quote author="toopay" date="1304709699"]What if you put that path directly into your browser? Is that generates the right image?[/quote]

Yes if i put the path directly in the browser i get the right image.
The problem is that i can't get it working with codeigniter Sad
#15

[eluser]toopay[/eluser]
Okey, this started sound UNBELIEVABLE, just make sure the file is exist, do this...
Code:
if (file_exists($imagepath))
{
    var_dump(file_get_contents($imagepath));
    /*
    $this->output->set_content_type('jpeg');
    $this->output->set_header('Content-Type: image/jpeg');
    $this->output->set_output(file_get_contents($imagepath));
    */
}
#16

[eluser]SoulM4n[/eluser]
[quote author="toopay" date="1304710802"]Okey, this started sound UNBELIEVABLE, just make sure the file is exist, do this...
Code:
if (file_exists($imagepath))
{
    var_dump(file_get_contents($imagepath));
    /*
    $this->output->set_content_type('jpeg');
    $this->output->set_header('Content-Type: image/jpeg');
    $this->output->set_output(file_get_contents($imagepath));
    */
}
[/quote]

Unbelievable is the right word ... i'm going crazy with this problem.

The file exist .. because with your code i get something like :

Code:
string(4658) "ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 90 ÿÛC     ÿÛC          ÿÀxx"ÿÄ     ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚     %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ     ÿĵw!1AQaq"2B‘¡±Á    #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvw


p.s. of course i had to cut the whole content of the page because it was huge

So the file exist and the path seems to be absolutely correct
#17

[eluser]toopay[/eluser]
What if you send the response manually :
Code:
// Uncomment var_dump, and replace with this...
header('Content-Type: image/jpeg');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. filesize($imagepath));
readfile($imagepath);
#18

[eluser]SoulM4n[/eluser]
[quote author="toopay" date="1304711935"]What if you send the response manually :
Code:
// Uncomment var_dump, and replace with this...
header('Content-Type: image/jpeg');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '. filesize($imagepath));
readfile($imagepath);
[/quote]

still nothing ... am i missing some library or helper ?
I don't even get any error so i really don't know how to solve ..
#19

[eluser]toopay[/eluser]
I dont have IIS server installed here, but i suspect thats the problems. In Apache, $_SERVER['DOCUMENT_ROOT'] should give you the right path of your application directory, and there is no need to include 'test' or doing some string replacement ('\' to '/'). Do you have Apache installed on your computer for compare?
#20

[eluser]SoulM4n[/eluser]
[quote author="toopay" date="1304713136"]I dont have IIS server installed here, but i suspect thats the problems. In Apache, $_SERVER['DOCUMENT_ROOT'] should give you the right path of your application directory, and there is no need to include 'test' or doing some string replacement ('\' to '/'). Do you have Apache installed on your computer for compare?[/quote]

I've just tried to upload everything in my test server (Linux + Apache + MySQL).

I always don't get anything in the output.
Of course if i try to dump the image with "var_dump" i get the content of the image.

That's crazy for me ...




Theme © iAndrew 2016 - Forum software by © MyBB