From 955d4a31298179ea0af156ad961280d1844b6544 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=B1=D0=B1=D0=B8?= <lsm@cesanta.com> Date: Tue, 21 Aug 2018 14:44:19 +0100 Subject: [PATCH] Fix file upload on windows CL: Fix https://github.com/cesanta/mongoose/issues/962 - file upload on windows PUBLISHED_FROM=85688eee147a1df468cca92f4ac61526ce9c02bf --- mongoose.c | 2 +- src/mg_http.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index d11756499..d09345c5e 100644 --- a/mongoose.c +++ b/mongoose.c @@ -8328,7 +8328,7 @@ void mg_file_upload_handler(struct mg_connection *nc, int ev, void *ev_data, if (lfn.p != mp->file_name) MG_FREE((char *) lfn.p); LOG(LL_DEBUG, ("%p Receiving file %s -> %s", nc, mp->file_name, fus->lfn)); - fus->fp = mg_fopen(fus->lfn, "w"); + fus->fp = mg_fopen(fus->lfn, "wb"); if (fus->fp == NULL) { mg_printf(nc, "HTTP/1.1 500 Internal Server Error\r\n" diff --git a/src/mg_http.c b/src/mg_http.c index 257bde4ce..dcf4c22da 100644 --- a/src/mg_http.c +++ b/src/mg_http.c @@ -2737,7 +2737,7 @@ void mg_file_upload_handler(struct mg_connection *nc, int ev, void *ev_data, if (lfn.p != mp->file_name) MG_FREE((char *) lfn.p); LOG(LL_DEBUG, ("%p Receiving file %s -> %s", nc, mp->file_name, fus->lfn)); - fus->fp = mg_fopen(fus->lfn, "w"); + fus->fp = mg_fopen(fus->lfn, "wb"); if (fus->fp == NULL) { mg_printf(nc, "HTTP/1.1 500 Internal Server Error\r\n" -- GitLab