Hi All,
I've worked some things out with regards to sending the contents of a file back to the httpd server with the HVAC webpage but I have a question that I'm hoping somebody can help with.
The key to getting the webpage to send the contents of the file when the "Submit" button is clicked on the form was to add the ENCTYPE="multipart/form-data" line to the <form /> tag like this:
<form name="HVAC" action="http:hvacoutput.cgi" ENCTYPE="multipart/form-data" method="POST">
<input type="file" id="img_file" name="img_file" />
... other <input /> tags as required
<input type="submit" value="Set">
<form />
Now, when the following code in the cgi_hvac_data(HTTPD_SESSION_STRUCT *session) function is run, the contents of the user selected file appears in "buffer" (along with values for the other <input /> tags).
if(session->request.content_len) { length = session->request.content_len; length = httpd_read(session, buffer, length); buffer[length] = 0; }
But, the MQX functions that were being used to parse the values from the various <input /> tags:
httpd_get_varval(session, buffer, "unit", unit, sizeof(unit))
no longer work properly. This is probably because the data stored in "buffer" is arranged differently and the functions are unable to isolate the "input=value" pairs. I'm sure I could write my own functions to parse the data in "buffer" to extract the "input=value" pairs data along with the contents of the file but I'm wondering if MQX already has functions to do this?
Thanks!
~Tim