[Klone-users] Download files
moises acuna
moises.acuna at gmail.com
Tue Jul 28 13:54:41 EDT 2009
Hello all,
my problem is this, my embedded web application generates binary files and
the user is capable to download them. I'm doing it like this:
while ((read = fread (buff, 1, BUFFER_SIZE, target)) == BUFFER_SIZE) {
io_write(out, buff, read);
}
// write the remaining data
if (!ferror(target) && feof(target)) {
io_write(out, buff, read);
}
2 issues:
1. when the file is smaller than BUFFER_SIZE its obvious that it doesn't get
into the while body but the fread is executed.
then by debugging i'm positive that the remaining data is executed and the
data is there in the buffer. But the download dialog in the browser doesn't
show up.
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'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.
Expecting for comments and thanks in advanced.
--
Moisés AAC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://koanlogic.com/pipermail/klone-users/attachments/20090728/80c091e2/attachment.htm
More information about the klone-users
mailing list