• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
force_download cutting off last few lines

#1
[eluser]dmorin[/eluser]
I'm creating a dynamic ics file and using the force_download helper to download it, however, the force_download helper is cutting off the last few lines. If I just echo the content directly to the screen, it's all there so it is definitely the download portion.

The only idea I have had is that it might have to do with the multi-byte characters that are included in the string, however, I'm overloading the strlen php function with mb_strlen and I even tried substituting it with mb_strlen in the download helper and that didn't work. I also tried manually adding in an encoding type of UTF-8 to the header and still nothing.

I saw one other post where someone else had this issue, but they didn't seem to find a solution. If anyone has any ideas, please let me know. Thanks.

#2
[eluser]dmorin[/eluser]
After thinking about this a little more, I realized what the issue was. The download helper includes this line:

Code:
header("Content-Length: ".strlen($data));

This approach to setting the content-length is flawed when using multi-byte strings IF strlen has been overloaded with mb_strlen in which case it will return the number of characters in the string as it is supposed to instead of the byte length.

Commenting out this line, which is not ideal, seems to have fixed my problem for now until I take the time to figure out how to calculate the actual byte length of the string.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.