7

I want to know if there is a way to send files to a website with sm ESP 8266 or any other IoT device. I intend that the IoT device will be the client. A PHP or scripting file on the website will act as the server. It will look like the IoT device is uploading the files to the website.

Aurora0001
  • 18,520
  • 13
  • 55
  • 169
Jojo
  • 73
  • 1
  • 4

2 Answers2

8

Typically, files are uploaded using a HTTP POST from a web form (I assume that's what you're thinking of when you say file upload). The exact format of the request tends to look a bit like this, as defined in RFC 1867.

The ESP8266 has an Arduino library, which contains a module called ESP8266HTTPClient. There's a basic example available here, to help get acquainted with the library, if you're interested.

The user 'gbafamily1' from the ESP8266 forums has created an example that POSTs a 256 byte file, data.bin to posttestserver.com. It should be relatively easy to adapt this to your needs, and I'd expect to use something like this on the server-side HTML:

<form action="posttestserver.com" method="post" enctype="multipart/form-data">
    <label for="file">Upload File:</label>
    <input type="file" name="testfile" />
    <input type="submit" />
</form>

Then, you could implement the server side in PHP to accept the file being uploaded. There is a reference available in the PHP documentation, and files sent by POST are stored in $_FILES.

With this example, the code above would allow browsers to upload, and the code provided by the ESP8266 forums would allow you to upload from the IoT device.

Aurora0001
  • 18,520
  • 13
  • 55
  • 169
0

Try this web server for IoT and realtime GPS tracking, https://iot.electronixforu.com It supports Passthrough mode of ESP8266, it means you can send data as fast as you can (normally 1 second interval), details are available at https://electronixforu.com/iot.html

Tarique
  • 11