Hello all,<br>my problem is this, my embedded web application generates binary files and the user is capable to download them. I&#39;m doing it like this:<br>   <br> while ((read = fread (buff, 1, BUFFER_SIZE, target)) == BUFFER_SIZE) {<br>
                    io_write(out,  buff, read);<br>  }<br>   // write the remaining data<br> if (!ferror(target) &amp;&amp; feof(target)) {<br>       io_write(out,  buff, read);<br>  }<br><br>2 issues:<br><br clear="all">
1. when the file is smaller than BUFFER_SIZE its obvious that it doesn&#39;t get into the while body but the fread is executed. <br>then by debugging i&#39;m positive that the remaining data is executed and the data is there in the buffer. But the download dialog in the browser doesn&#39;t show up. <br>
<br>2. when the file is bigger than the BUFFER_SIZE the dialog does come up and you can download the file, by debugging you can see the first iteration of the while and the content of the buffer but when it finish the downloaded file has 2 extra bytes at the beginning:  0A and 0D, these are new line and carriage return characters, the curious thing is that those characters are not in the buff array. I&#39;ve tried to flush the out variable, to use the seek function , but nothing. If anyone had this very problem and/or knows how to solve it. <br>
<br>Expecting for comments and thanks in advanced. <br><br><br><br><br>-- <br>Moisés AAC<br>