我正在使用cpp-httplib,并且试图将文件上传到https://ptsv2.com之类的后期测试服务器。我不太了解给定的文件上传文档,我有点理解您必须使用Multipart / form-data才能上传文件。
文档中给定的代码是这个
httplib::MultipartFormDataItems items = {
{ "text1", "text default", "", "" },
{ "text2", "aωb", "", "" },
{ "file1", "h\ne\n\nl\nl\no\n", "hello.txt", "text/plain" },
{ "file2", "{\n \"world\", true\n}\n", "world.json", "application/json" },
{ "file3", "", "", "application/octet-stream" },
};
auto res = cli.Post("/multipart", items);
在file1中,您可以看到它正在服务器上创建文件并将其命名为hello.txt。 如何编写它,以便可以将设备上的文件上传到服务器上?
任何建议都会有所帮助。谢谢。
答案 0 :(得分:0)
根据@Botje 和 cpp-httplib 文档
relu