Welcome Guest, Not a member yet? Register   Sign In
Zip and Download
#1

[eluser]yannyannyann[/eluser]
Hello all ,

I am trying to use the DOWNLOAD Helper as well as the ZIP CLASS without success.

I would like to zip 3 JPGs and download them.


I have tried using these lines from the controler,
Code:
$data = file_get_contents("./public/photos/highres/1afc8_9_2009-03-20.jpg");
$name= '1afc8_9_2009-03-20.jpg';
force_download($name, $data);

or

Code:
$this->zip->read_file("./public/photos/highres/1afc8_9_2009-03-20.jpg");
$this->zip->download('test.zip');

But I am having the header error :
Code:
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Users/......./system/application/models/media_model.php:538)
Filename: helpers/download_helper.php
Line Number: 86


I need help !! Smile


thanks in advance !!
#2

[eluser]vitoco[/eluser]
Code:
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Users/......./system/application/models/media_model.php:538)
Filename: helpers/download_helper.php
Line Number: 86

This indicates that you already s send some output to the browser before send the file , this generally occurs from an
Code:
echo $something ;
// in line 538 ( output started at /Users/......./system/application/models/media_model.php)

or in many cases , because some space at the end of the file after the php closing tag ?>

So, check the model ( line 538 ) , remove all "echoS" an trim the spaces at the begin and end of file.
#3

[eluser]yannyannyann[/eluser]
I love you Smile

No, seriously, the problem was that I had spaces and return line after the final php closing tag ?>

Thanks !
#4

[eluser]vitoco[/eluser]
[quote author="yannyannyann" date="1237916408"]I love you Smile
No, seriously, the problem was that I had spaces and return line after the final php closing tag ?>
[/quote]
;-)

been there, done that ...

Many hours looking for that mistake...change my code many many many times to find out that was only a space making my life miserable.

Saludos
#5

[eluser]Daniel Moore[/eluser]
This is exactly why the later versions of CodeIgniter recommend that you leave off the closing tag ?>.

I have been using:
// end of file: this_filename.php

instead of:
?>

and have been doing this for quite some time now. It saves a lot of headaches in this department.

As PHP doesn't require a closing tag, it's best to just leave it off, unless you are doing inline PHP.
#6

[eluser]vitoco[/eluser]
i didn't know that...thanks
#7

[eluser]yannyannyann[/eluser]
yeah i was wondering sometimes why there was no closing tags in some helpers ...
#8

[eluser]Unknown[/eluser]
<a href="http://ellislab.com/codeigniter/user-guide/general/styleguide.html#php_closing_tag">Codeigniter style guide </a>

It's worth reading the style guide - I picked up the end of file thing and a few other shortcuts/better methods.




Theme © iAndrew 2016 - Forum software by © MyBB