From 322ed3cc6f12fd072b0ded0d0d248ef339d0bd7d Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Mon, 21 Jan 2013 01:39:14 +0000 Subject: [PATCH] fflush()-ing uploaded file before calling MG_UPLOAD callback --- mongoose.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mongoose.c b/mongoose.c index 7c1529a9..a29539e7 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4191,7 +4191,8 @@ int mg_upload(struct mg_connection *conn, const char *destination_dir) { if (!memcmp(&buf[i], "\r\n--", 4) && !memcmp(&buf[i + 4], boundary, boundary_len)) { // Found boundary, that's the end of file data. - (void) fwrite(buf, 1, i, fp); + fwrite(buf, 1, i, fp); + fflush(fp); num_uploaded_files++; conn->request_info.ev_data = (void *) path; call_user(conn, MG_UPLOAD);