cgi icon indicating copy to clipboard operation
cgi copied to clipboard

CGI POST multipart/form-data deletes uploaded files before application can access them

Open shattar opened this issue 6 years ago • 0 comments

When "BOOST_CGI_KEEP_FILE_UPLOADS" is not defined and "BOOST_CGI_NO_BOOST_FILESYSTEM" is not defined, the form_part destructor deletes the file. This sounds good, except for when the form_part is a local variable in the form_parser::parse_form_part method and the file gets deleted when the local variable goes out of scope. So, what ends up happening is that the form_parser::parse_form_part method parses the part, creates the file, then deletes it upon return.

I ended up defining "BOOST_CGI_KEEP_FILE_UPLOADS" and handled cleaning up the uploaded files at the application level.

shattar avatar Feb 01 '19 22:02 shattar