ESP32_curl_example icon indicating copy to clipboard operation
ESP32_curl_example copied to clipboard

curl_easy_perform failed: Failed to open/read local data from file/application

Open KishanPala556 opened this issue 4 years ago • 0 comments

I am using the same library to send a spiffs .txt file in my custom code, I have ESP32, 16 MB with custom partition table. I am getting this error while sending file in testPOST function. Here is the code snippets:

#define DIAGNOSIS_FILE "/spiffs/diagnosis.txt" char cTempString[] = "Diagnosis status testing";

fd =fopen(DIAGNOSIS_FILE, "wb"); if (fd) { fwrite(cTempString, 1, strlen(cTempString), fd); fclose(fd); printf("Save string to file\r\n"); }

 curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "param3", CURLFORM_COPYCONTENTS, "Test from ESP32", CURLFORM_END);
// add file parameter

fd = fopen(DIAGNOSIS_FILE, "r");
if (fd == NULL) {
	ESP_LOGI(tag, "file:%s does not exist",DIAGNOSIS_FILE);
} else {
	curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "file", CURLFORM_FILE, DIAGNOSIS_FILE, CURLFORM_END);
	fclose(fd);
}

int res = Curl_POST(Post_testURL, hdrbuf, bodybuf, 1024, 4096);
print_response(hdrbuf, bodybuf,res);

KishanPala556 avatar Apr 21 '21 07:04 KishanPala556