Download image with Zend - PHP header: wrong file format
First of all, I know this question has already been asked but I can't solve it anyway.
I need to set a link to download images(jpg).
I read various posts found here and with google but it's always the same results:
I can download the file but it's still the same error. The jpeg format is not correct.

> Erreur d'interprétation du fichier
> d'image JPEG (Not a JPEG file: starts
> with 0x0a 0x20)

When I test this in a file without a controller, it's ok but the script in a controller doesn't work.

Here is the code for tests:

     $file = '{document_root}/www/themes/default/images/common/background1.jpg';
    
    if (file_exists($file))
    {
        header('Content-type: application/octet-stream');
        header('Content-Disposition: attachment; filename=' . basename($file));
        header('Content-length: ' . filesize($file));
                
        readfile($file);
        exit;
    }
This code works in a simple php file. I download the picture and can open it.
But within my controller, the file is not good.

I found that the tag ?> can add spaces but my controllers doesn't have this closing tag.
I've tested some code with the Zend objects found in various posts but it's the same error.

I assume there's something wrong with my Zend controller.

Any clue will be really appreciated.
Thanks for your help and sorry for my bad english.
Download image with Zend - PHP header: wrong file format
===

First of all, I know this question has already been asked but I can't solve it anyway.
I need to set a link to download images(jpg).
I read various posts found here and with google but it's always the same results:
I can download the file but it's still the same error. The jpeg format is not correct.

> Erreur d'interprétation du fichier
> d'image JPEG (Not a JPEG file: starts
> with 0x0a 0x20)

When I test this in a file without a controller, it's ok but the script in a controller doesn't work.

Here is the code for tests:

     $file = '{document_root}/www/themes/default/images/common/background1.jpg';
    
    if (file_exists($file))
    {
        header('Content-type: application/octet-stream');
        header('Content-Disposition: attachment; filename=' . basename($file));
        header('Content-length: ' . filesize($file));
                
        readfile($file);
        exit;
    }
This code works in a simple php file. I download the picture and can open it.
But within my controller, the file is not good.

I found that the tag ?> can add spaces but my controllers doesn't have this closing tag.
I've tested some code with the Zend objects found in various posts but it's the same error.

I assume there's something wrong with my Zend controller.

Any clue will be really appreciated.
Thanks for your help and sorry for my bad english.