Thailand Love U Thailand Love U - 5 months ago 10x
PHP Question

Response::download make data in txt file loss

I have abc.txt on the public path and it contain string "Hello World" (line 1)

After I use

return Response::download(public_path()."/file/abc.txt");

the file will download correctly to browser (Chrome & Firefox) but data in file will change to

Hello Wor

And have invisible string in line 1 (not sure it is \r\n) and "Hello Wor" move to line 2

I use

$headers = array('Content-Type: text/plain');
return Response::download(public_path() ."/file/abc.txt","abc.txt",$headers);

But problem not to resolved. Sorry for my bad grammar in English.
Thank you for any help.


After a few days I can solve my problem by this code...

$res = Response::download(public_path() ."/file/abc.txt","abc.txt",$headers);
return $res;

It clear.