Thursday, July 19, 2012

Re: File Downloads corrupted with CRLF at beginning

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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: