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.


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" />

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.

  • I am actually a newbie to php, can you help with a simple php code that will accept the file from the esp8266. Or if you have an example that can be adapted. – Jojo Jun 6 '17 at 17:41
  • @Jojo The PHP documentation contains a good reference and set of examples. You should be able to learn what you need from there. If you have any problems, they'd be best asked at Stack Overflow, since PHP isn't really an IoT topic in itself. – Aurora0001 Jun 6 '17 at 17:43

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.