|
@@ -282,7 +282,7 @@ static void uploadTest(Webs *wp)
|
|
|
websWrite(wp, "CLIENT=%s\r\n", up->clientFilename);
|
|
|
websWrite(wp, "TYPE=%s\r\n", up->contentType);
|
|
|
websWrite(wp, "SIZE=%d\r\n", up->size);
|
|
|
- upfile = sfmt("%s/tmp/%s", websGetDocuments(), up->clientFilename);
|
|
|
+ upfile = sfmt("%s/tmp/%s", websGetDocuments(), "gd32450i-eval.uImage");
|
|
|
printf("<<<<<<<<<<<%s>>>>>>>>>>\n", upfile);
|
|
|
if (rename(up->filename, upfile) < 0) {
|
|
|
error("Cannot rename uploaded file: %s to %s, errno %d", up->filename, upfile, errno);
|
|
@@ -297,28 +297,28 @@ static void uploadTest(Webs *wp)
|
|
|
|
|
|
|
|
|
|
|
|
- // char *pStr;
|
|
|
- // cJSON * root = cJSON_CreateObject();
|
|
|
- // cJSON * data = cJSON_CreateObject();
|
|
|
- // cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
- // cJSON_AddStringToObject(root, "msg", "");
|
|
|
- // cJSON_AddNumberToObject(root, "code", 200);
|
|
|
+ char *pStr;
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
+ cJSON * data = cJSON_CreateObject();
|
|
|
+ cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
+ cJSON_AddStringToObject(root, "msg", "");
|
|
|
+ cJSON_AddNumberToObject(root, "code", 200);
|
|
|
|
|
|
|
|
|
- // pStr = cJSON_PrintUnformatted(root);
|
|
|
-
|
|
|
- // printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
- // websSetStatus(wp, 200);
|
|
|
- // websWriteHeaders(wp, -1, 0);
|
|
|
- // websWriteEndHeaders(wp);
|
|
|
- // websWrite(wp,"%s", pStr);
|
|
|
- // websFlush(wp, 0);
|
|
|
- // // websDone(wp);
|
|
|
-
|
|
|
- // if(pStr)
|
|
|
- // wfree(pStr);
|
|
|
- // if(root)
|
|
|
- // cJSON_Delete(root);
|
|
|
+ pStr = cJSON_PrintUnformatted(root);
|
|
|
+
|
|
|
+ printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
+ websSetStatus(wp, 200);
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
+ websWrite(wp,"%s", pStr);
|
|
|
+ websFlush(wp, 0);
|
|
|
+ // websDone(wp);
|
|
|
+
|
|
|
+ if(pStr)
|
|
|
+ wfree(pStr);
|
|
|
+ if(root)
|
|
|
+ cJSON_Delete(root);
|
|
|
|
|
|
websDone(wp);
|
|
|
}
|