File Downloads corrupted with CRLF at beginning

2012-07-19 Thread Ernesto
Hi all

i have an action wich generates a CSV list that the user can download.
This CSV gets corrupted by a CRLF placed at the beginning of the file.

i tried these 2 ways:

*A - using CakeResponse and passing the fileContent directly, without 
creating any file*
$this-autoRender = false;
$this-response-type(application/csv);
$this-response-download(list.csv);
$this-response-body($fileContent);

*B - writing a file on server's hdd and then download it using MediaView*
App::uses(File, Utility);
$file = new File ($filePath . $fileName, true);
$file-write($listaTaglio);
$file-close();
$this-viewClass = Media;

$this-set(array(
id= $fileName,
download  = true,
path  = $filePath
));
*
*
In both cases i get the same issue.
My server runs on W7Pro, PHP 5.3.13, Apache 2.2.22
Any clue?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: File Downloads corrupted with CRLF at beginning

2012-07-19 Thread Ernesto
i forgot to say that the generated file in method B doesn't have the 
starting CRLF

Il giorno giovedì 19 luglio 2012 17:10:08 UTC+2, Ernesto ha scritto:

 Hi all

 i have an action wich generates a CSV list that the user can download.
 This CSV gets corrupted by a CRLF placed at the beginning of the file.

 i tried these 2 ways:

 *A - using CakeResponse and passing the fileContent directly, without 
 creating any file*
 $this-autoRender = false;
 $this-response-type(application/csv);
 $this-response-download(list.csv);
 $this-response-body($fileContent);

 *B - writing a file on server's hdd and then download it using MediaView*
 App::uses(File, Utility);
 $file = new File ($filePath . $fileName, true);
 $file-write($listaTaglio);
 $file-close();
 $this-viewClass = Media;

 $this-set(array(
 id= $fileName,
 download  = true,
 path  = $filePath
 ));
 *
 *
 In both cases i get the same issue.
 My server runs on W7Pro, PHP 5.3.13, Apache 2.2.22
 Any clue?



-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: File Downloads corrupted with CRLF at beginning

2012-07-19 Thread Ernesto
i solved :)

the issues were a double CRLF after the PHP closing tag in one of my helpers

Il giorno giovedì 19 luglio 2012 17:10:08 UTC+2, Ernesto ha scritto:

 Hi all

 i have an action wich generates a CSV list that the user can download.
 This CSV gets corrupted by a CRLF placed at the beginning of the file.

 i tried these 2 ways:

 *A - using CakeResponse and passing the fileContent directly, without 
 creating any file*
 $this-autoRender = false;
 $this-response-type(application/csv);
 $this-response-download(list.csv);
 $this-response-body($fileContent);

 *B - writing a file on server's hdd and then download it using MediaView*
 App::uses(File, Utility);
 $file = new File ($filePath . $fileName, true);
 $file-write($listaTaglio);
 $file-close();
 $this-viewClass = Media;

 $this-set(array(
 id= $fileName,
 download  = true,
 path  = $filePath
 ));
 *
 *
 In both cases i get the same issue.
 My server runs on W7Pro, PHP 5.3.13, Apache 2.2.22
 Any clue?



-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: File Downloads corrupted with CRLF at beginning

2012-07-19 Thread Dr. Tarique Sani
On Thu, Jul 19, 2012 at 8:58 PM, Ernesto e.fanz...@gmail.com wrote:
 i solved :)

 the issues were a double CRLF after the PHP closing tag in one of my helpers

Reason to not use the closing tag in pure php files

:-)

Tarique

-- 
=
PHP for E-Biz: http://sanisoft.com
=

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php