1

I am trying to convert a http form with input fields into a basic file that I can throw into my microcontroller code. I am missing something basic, because the server is not accepting the value. Here is the code after I tried to convert it to name value pairs from input fields

<html>
<body>
    <form action="website"
        enctype="multipart/form-data" method="post">
        <utcdatatime="2013-06-16T23:20:40"&leftsource="1"&rightsource="1"&automatictransfer="1"&eventstatus="1"&preferred="1">
    </form>
</body>
</html>

Here is the input field version:

<html>
<body>
    <form action="website"
        enctype="multipart/form-data" method="post">

                    <input type="text" name="utcdatatime" size="20" value="2013-06-16T23:20:40" />

                    <input type="text" name="leftsource" size="2" value="1" />

                    <input type="text" name="rightsource" size="2" value="4" />

                    <input type="text" name="automatictransfer" size="2" value="4" />

                    <input type="text" name="eventstatus" size="2" value="2" />

                    <input type="text" name="preferred" size="2" value="1" />
                    <input type="submit" value="Send" />
    </form>
</body>
</html>

I was able to get a basic post, but this code is pretty heavy for an arduino to build up and then send, I also can't get the / on the second line to work in the Arduino but I think I'll figure that out

POST /post_url.php HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Content-Type: multipart/form-data; boundary=---------------------------7dd35a2aab1494
Accept-Encoding: gzip, deflate
Content-Length: 1018
DNT: 1
Host: website
Pragma: no-cache

-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="customerkey"

3432-1GH4-88RG-7B2A
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="responsetype"

simple
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="filetype"

sandc_microat
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="gatewayid"

0011223355AA
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="leftsource"

1
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="rightsource"

4
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="automatictransfer"

4
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="eventstatus"

2
-----------------------------7dd35a2aab1494
Content-Disposition: form-data; name="automatictransfer"

1
-----------------------------7dd35a2aab1494--

========================== POST END=================================

1 Answer 1

2

why can't you use the input version? You could always use 'hidden' fields instead of 'text' fields:

<input type="hidden" name="rightsource" value="4" /> <!-- size attr not required -->

Also unless you are posting (uploading) files, I'm pretty sure you don't need the enctype, this will insert mime data into the post, you could just remove it.

this js fiddle should show an example of a post to suit your requirements, this creates a post request on the arduino system and sends it to website/post_url.php:

http://jsfiddle.net/terrykernan/8z2VF/

Sign up to request clarification or add additional context in comments.

4 Comments

I am trying to convert it to a POST so I can have a microcontroller (Arduino) compile and POST this itself.
if you do a simple post without the enctype, does the arduino pick that up?
The enctype is set. I don't understand what you mean the arduino pick it up? I am having the arduino make this post to a server.
ah in that case I think I know what you are trying to do, my answer has been updated

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.