I also did update my php server with an POST command.
Perhaps this can help you as a way to send your file.
FILE *fp = fopen("/local/calib.txt", "r");
if (fp==NULL) printf ("Error opening calib.txt file\n");
fscanf(fp, "%d,%d,%d,%d,%d,%d,%d,", &LOG,&E1,&E2,&G1,&G2,&W1,&W2);
fscanf(fp, "%s\n", URL);
fclose(fp);
if (htmlflag) { //every 5 minutes this htmlflag gets true
Gr=1;
htmlflag=false;
char data[16]={0};
HTTPClient myhttp;
HTTPMap msg;
snprintf(data, 16, "%d", packet_ID);
msg["t1"]=data;
snprintf(data, 16, "%d", Gas);
msg["t2"]=data;
snprintf(data, 16, "%d", Water);
msg["t3"]=data;
snprintf(data, 16, "%d", Elektriciteit);
msg["t4"]=data;
msg["t5"]="1013";
snprintf(data, 16, "%d", buitentemperatuur);
msg["t6"]=data;
snprintf(data, 16, "%d", binnentemperatuur);
msg["t7"]=data;
myhttp.basicAuth("xxxxxxx","xxxxxxxx");
HTTPResult r = myhttp.post(URL, msg, NULL);
if (r == HTTP_OK)
{
printf("succesfull timestamp update\n");
packet_ID++;
}
else
{
printf("problem occured, returncode%d\n",r);
}
I hope this will work for your.
Hello guys,
I am trying to send a txt file using a POST request with the HTTPClient library. I therefore use a HTTPFile as arguement for the post call. On the server, which gets the file, runs a php script, which grabs the filename using $_FILE['userfile]['name'] and processes the file. What happens right now is, "userfile can not be found". This array ($_FILE) actually doesn't exist. So I assume the http header is not good. I have to add some metadata that usually is given when you upload a file using a html form. The mBed request has to look to the server like a usual upload through such a form.
Does anybody know how to do this. I experimented around with the setRequestHeader() function of the HTTPClient class, but didn't get to anything. My code looks like this right now:
I desperately need this thing done.
Thanks to anyone.