Skip to content

Commit

Permalink
Added workaround for sending the selected file size
Browse files Browse the repository at this point in the history
The file content-length header is of by +/- 200 bytes. Known issue: esp8266/Arduino#3787)
  • Loading branch information
Onno-Dirkzwager authored Dec 23, 2018
1 parent 688ebe9 commit 6cdabc1
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions examples/UploadServer/data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,25 @@
<body>
<h3>Choose .tft file to upload</h3>
<form method="post" enctype="multipart/form-data">
<input type="file" name="name">
<input class="button" type="submit" value="Upload & Update">
<input type="file" name="name" onchange="valSize(this)">
<input class="button" type="submit" value="Upload & Update" disabled>
</form>
<script>
function valSize(file){
// get the selected file size and send it to the ESP
var fs = file.files[0].size;
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(this.readyState == 4 && this.status == 200){
// ESP received fileSize enable the submit button
document.getElementById("button").disabled = false;
}
};
xhttp.open("POST", "/fs", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("fileSize="+fs);
}
</script>
<p>Updating might take a while if you have complex .tft file. Check Nextion display for progress.</p>
</body>
</html>
</html>

0 comments on commit 6cdabc1

Please sign in to comment.