First you would have to create a function that reads the file from the SD car a bit like while (!eof(file) Serial.println(file.read) and having read a line in from the file, then send the line to another function that will make a connection to your server and upload the data, then repeat until eof. I have no further details to help out more.
Very nice indeed, installed the code and I like the tidy looks of the web interface. Are you still developing this software, can't seem to find the announced next versions with directory listing, delete functions and so on. If you stopped with it, I'll have to do it myself, quite a challenge I guess ;-) Thanks anyway, got me half the way of jukebox project I have in mind, that should send mp3 files to a sonos box. Your code will be used to maintain the collection of music files that the jukebox makes available. Thank you for that!
Frank, all the code is finished there is a full version if you follow the TN video series so this TN then the next adds more features through to the final version with all the functions.
@@G6EJD Thank you! Found it, and used version V01 which works. Have not looked into V02 (same description) or V03 (diagnostic version) yet. It is actually my very first project with a ESP32 wroom board, so I feel like Alice in Wonderland - luckily I used to program in C long time ago, so with some head scratching I am slowly making some progress. Thanks again for getting me started.
Frank, the diagnostic version is provided to determine if there are any WiFi connection issues, together with any JSON diagnostics as the weather server can sometimes issue a lot more data than is expected.
I have to send video(mp4 1MB) from my pc program(c# form application) to the esp8266 or raspberry over wifi. I have to save to sd card in esp8266. I don't want send video from browser. How can i do this? thx
You’d have to use FTP to do that there are quite a few examples around. You can use the Asynchronous Webserver to do it too. Complicated but the examples will show the way.
Thanks again. A request although your videos are focused on esp32 programming and functions, can you also make a video sometime about how you make that html interface? Do i need to know html scripting or is there any hui based software that can at least give us basic html script that we can later transfer into esp32 sketch as you do?
OK noted. When I publish the next video with the completed code of upload, download, delete, stream and directory functions I'll go through some of the code details, I'll probably explain how the Client requests are handled, then how the pages are built in HTNL and how CSS is used to format the HTML but in essence most of this could be stripped right back to a bare-bones system that still works without all the colour and object embellishments although using CSS forms does make changing the design quite easy. If you go to the CSS tab you will see the CSS elements for say an HTML and you can change the width, etc, I've tried to make the descriptions self-documenting. regarding the pages themselves they are all (simple) HTML and they are constructed by adding a standard HTML page header, then the body section and then finally the HTML footer section all needed for a correctly structured HTML page and for your browser to display the result. So there is no scripting involved its all HTML plus the Arduino variables that are combined together to display the HTML. Example: Say we want to display a variable called 'temperature' in HTML we'd need to embody that in some HTML mark-up, let's us use for example the paragraph element, ordinarily we'd do this: String webpage = "The temperature is 26°c" so now let's change that fixed element to use the variable, then it becomes: String webpage = "The temperature is"+String(temperature)+"°c";Now it will print the same but from one of your variables, temperature in this example.To send the HTML to the Client there are a couple of techniques either send a whole page using some arbitrary variable I use 'webpage' and you keep adding to it. So in the code you will see that I start by adding all the header stuff to webpage, then with webpage += I add all the middle sections and then finally I add the footers then send the whole variable back to the client with server.send(200, ""text/html, webpage);So that's a quick overview but I hope from that you can read the code a little more easily now, but yes I will explain the concepts some more in the next video in the next few days. Dave.
Good project, but I have a problem, when I upload a file I have an error message "Could not create file loaded (write protected?)", Is this because I am not used SD card?
No SPIFFS will work the same, but the environment for SPIFFS has to be setup correctly first. Has you formatted SPIFFS? Have you started SPIFFS? I can't help because I have no information from you.
Christian Dave Tipactipac, unfortunately there are some limitations with the ESP filing system. On the ESP8266 it can use folders e.g. /data but on the ESP32 there are no folders just pseudo folders by prefixing the file name with /data and /data acts as a filter with all files existing at the top level. You could add some copy commands to the code after upload.
Christian Dave Tipactipac, the ESP filing system does not support wildcards so you have to specify each file. It’s a basic filing system noting it’s a micro-controller.
Well, to be honest there is no deterministic means of calculating that, the ESP libraries use http so the overheads are higher than an ftp transfer, each packet size is about 1600 bytes or 32768 packets, but what is a packet speed, who knows, so many variables based on path to server and network performance, to name a few, but I’d expect it to take many minutes, from about 3 to 30 minutes m, it’s not a desktop PC. Try it out is the answer.
Hi, what does this code exactly do and when to use it, what is it about with these brackets? in server.on I found this expression: [](){ server.send(200)}
This code runs up a ESP based WebServer, and then from the menu, you can select a file using your PC Browser and then upload the file to the ESP8266/ESP32 filing system e.g. SD card or SPIFFS. [](){server send(200)} are just empty parameters and the code 200 means HTTP OK because it's a standard response for to a successful HTTP request.
Good morning, yes I understrand that, but usualy I use the instruction in this way:"server.on("/wifi_connect", HTTP_POST, handlewifi);" to call a subroutine. But now we got these brackets like this: "server.on("/update", HTTP_POST, []() { server.sendHeader("Connection", "close"); server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK"); ESP.restart(); }, []() {....more functions......}); Do you know where there is a reference and explained, how to use it?
SV Vela Nautica, you need to go to the web server repository on git hub, then scroll down the .cpp to send and check out the parameters. There is no documentation that explains what you want to know, if only there was!
Ok, then let me ask other way round, maybe you know? here my example again: HTTP_POST, []() { server.sendHeader("Connection", "close"); server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK"); ESP.restart(); }, []() {....more functions......}); I like to separate all what is in the last curly bracket into a separate subroutine. I tried to replace [] by a function name but that did not work.Do you know how to? -Oliver-
You can't do it the way your trying to do, there are separate commands that you need to use with the Webserver: server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); server.setContentLength(CONTENT_LENGTH_UNKNOWN); server.send(200, "text/html", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. server.sendContent(webpage); server.client().stop(); // Stop is needed because no content length was sent You need to ask the author of the Webserver why you can't use functions, that's Espressif, your trying to do something the server was not designed to do.
hin124 It uploads a 20K file in about 1-2 secs I have not done an accurate measurement but it’s near instantaneous. Obviously this is a micro controller so don’t expect Desktop PC performance.
That sounds about right to me, the http protocol results in a large overhead, but it’s the only provolones that is supported by the IDE as standard there are some ftp libraries around but they are difficult to interface with for the HCI
You can upload any file type the ESP sketch does not care, it's a binary payload whatever it happens to be when interpreted by say a browser or some other application. It can relatively easily be switched to an Access point, just prefix wifi.begin with the required mode. There is plenty of documentation via google on how to do this.
Good luck with your project, there is a more advanced version with dir, upload and download with delete, I’m sure you’ve seen this version. See github.
@@Genericuseron hey,i am also doing similar project,i could not upload not-writable files like pdfs,i can upload images,but they are downloaded in unreadable fomat .did it work for you?
I'm using SDHC cards and currently a Samsung 64GB card is working just fine. The file format is FAT so no files more than 4GB. Essentially (I have not tried it all) I'd expect the SD library using FAT to do everything a PC can do using SD cards of the same size. I know 512GB cards have been used on an ESP8266 and that's the same library. In practice and for most applications a file of data of about 10MB is huge, so getting near the 1GB sizes and FAT maximum will be 4GB is extremely large files. I have not done any benchmarks but it might be slow reading through the files, but workable.
The http protocol overheads are large and generally a 20K file takes about 2-secs, the ESP8266 compiler/http implementation along with all other webserver functions is faster than the ESP32 in all regards. I think the eSP8266 had a lot more compiler development than the ESP32 so-far.
@@สุพงศ์เอง Your phone can connect to the ESP32 and yes will use http like it does for all web pages, you would select the file to upload and then upload it
@@G6EJD Hi, really great video. Howeverm the version on the github appears to be missing the directory option. Could you update the version please? Thank you. Cheers, Luís Pereira.
@@G6EJD You're right. The 'directory' version is on the repository: github.com/G6EJD/G6EJD-ESP-File-Server, and not the repository referred on the video description, correct? Thank you.
Do you mean transfer a single file or to stream it? You can transfer a file but using http will take some time (many minutes) to complete. I have not produced a streaming version.
@@G6EJD Yes, i mean a single file. Maximum 1mb video file will be sended. Aproximately how much time will it take to send video? http is not the right way to do it? My project is that connect from Pc to Esp and send 1mb(max.) video file. Do you have any idea for this? Which one is the right way to do it?
@@kemrandavrishov9341 it’s difficult to determine the exact transfer time the best way to find out how long is to transfer and time a 1K file, then 10K and 100K from the timings it’s easy to work out the 1MB transfer time. You have no choice about transfer protocol as it can only be done using http. There are some ftp libraries around but they are harder to use/integrate with code and are a bit experimental.
@@G6EJD First of all thank you so much. İ need send video from Ground station program(python desktop application) to the esp3286 over wifi. İ only need select video from GCS program and click the send button to send video.İ actually dont know web interface is necessary for me? İ dont wanna send video from browser. How can i do it?
Well you can, have you tried it, but do t forget the ESP32 has relatively limited memory and it’s not a PC and was never designed to handle large files.
Great tutorial. I will add it one of my datalogger. Thank you.
That upload function seems neat, I will have to play with that upload code, interesting how it seems the uploaded file comes in little chunks.
jontscott More likely packet payload sizes and it does take some time to transfer say 50K and the SD Filing system is not that fast.
jontscott I added a link to the HTTPupload source in the ESP core you can see how it operates in there under the webserver.
Nice Tech note Dave. Looking forward to see your next Tech note. Thanks.
Nice update!
This is really useful, thank you for the contribution!
Hi bro,
i have a doubt, in esp32 project.
i want to upload a Notepad file from SD Card module to Firebase Storage.
please suggest me..
First you would have to create a function that reads the file from the SD car a bit like while (!eof(file) Serial.println(file.read) and having read a line in from the file, then send the line to another function that will make a connection to your server and upload the data, then repeat until eof. I have no further details to help out more.
Very nice indeed, installed the code and I like the tidy looks of the web interface. Are you still developing this software, can't seem to find the announced next versions with directory listing, delete functions and so on. If you stopped with it, I'll have to do it myself, quite a challenge I guess ;-) Thanks anyway, got me half the way of jukebox project I have in mind, that should send mp3 files to a sonos box. Your code will be used to maintain the collection of music files that the jukebox makes available. Thank you for that!
Frank, all the code is finished there is a full version if you follow the TN video series so this TN then the next adds more features through to the final version with all the functions.
@@G6EJD Thank you! Found it, and used version V01 which works. Have not looked into V02 (same description) or V03 (diagnostic version) yet. It is actually my very first project with a ESP32 wroom board, so I feel like Alice in Wonderland - luckily I used to program in C long time ago, so with some head scratching I am slowly making some progress. Thanks again for getting me started.
Frank, the diagnostic version is provided to determine if there are any WiFi connection issues, together with any JSON diagnostics as the weather server can sometimes issue a lot more data than is expected.
I have to send video(mp4 1MB) from my pc program(c# form application) to the esp8266 or raspberry over wifi. I have to save to sd card in esp8266. I don't want send video from browser. How can i do this? thx
You’d have to use FTP to do that there are quite a few examples around. You can use the Asynchronous Webserver to do it too. Complicated but the examples will show the way.
Thanks again. A request although your videos are focused on esp32 programming and functions, can you also make a video sometime about how you make that html interface? Do i need to know html scripting or is there any hui based software that can at least give us basic html script that we can later transfer into esp32 sketch as you do?
OK noted. When I publish the next video with the completed code of upload, download, delete, stream and directory functions I'll go through some of the code details, I'll probably explain how the Client requests are handled, then how the pages are built in HTNL and how CSS is used to format the HTML but in essence most of this could be stripped right back to a bare-bones system that still works without all the colour and object embellishments although using CSS forms does make changing the design quite easy. If you go to the CSS tab you will see the CSS elements for say an HTML and you can change the width, etc, I've tried to make the descriptions self-documenting. regarding the pages themselves they are all (simple) HTML and they are constructed by adding a standard HTML page header, then the body section and then finally the HTML footer section all needed for a correctly structured HTML page and for your browser to display the result. So there is no scripting involved its all HTML plus the Arduino variables that are combined together to display the HTML. Example:
Say we want to display a variable called 'temperature' in HTML we'd need to embody that in some HTML mark-up, let's us use for example the paragraph element, ordinarily we'd do this:
String webpage = "The temperature is 26°c" so now let's change that fixed element to use the variable, then it becomes:
String webpage = "The temperature is"+String(temperature)+"°c";Now it will print the same but from one of your variables, temperature in this example.To send the HTML to the Client there are a couple of techniques either send a whole page using some arbitrary variable I use 'webpage' and you keep adding to it. So in the code you will see that I start by adding all the header stuff to webpage, then with webpage += I add all the middle sections and then finally I add the footers then send the whole variable back to the client with server.send(200, ""text/html, webpage);So that's a quick overview but I hope from that you can read the code a little more easily now, but yes I will explain the concepts some more in the next video in the next few days. Dave.
G6EJD i am extremely thank full to you for beautiful precise perfect explanation and guide. I saw your latest video and learnt a lot.
Good project, but I have a problem, when I upload a file I have an error message "Could not create file loaded (write protected?)", Is this because I am not used SD card?
No SPIFFS will work the same, but the environment for SPIFFS has to be setup correctly first. Has you formatted SPIFFS? Have you started SPIFFS? I can't help because I have no information from you.
So clear; so clean, love it!
like poetry
Hello, is there a way after uploading a file, it then stored automatically to a specific folder? Or create a new folder then store there? Thank you
Christian Dave Tipactipac, unfortunately there are some limitations with the ESP filing system. On the ESP8266 it can use folders e.g. /data but on the ESP32 there are no folders just pseudo folders by prefixing the file name with /data and /data acts as a filter with all files existing at the top level. You could add some copy commands to the code after upload.
@@G6EJD Okay sir, thank you.
But when I download it sir? Do I need to specify the entire location/directory? Or it downloads the whole folder?
Christian Dave Tipactipac, the ESP filing system does not support wildcards so you have to specify each file. It’s a basic filing system noting it’s a micro-controller.
how long would a 50mb file take to upload from an ssl server?
Well, to be honest there is no deterministic means of calculating that, the ESP libraries use http so the overheads are higher than an ftp transfer, each packet size is about 1600 bytes or 32768 packets, but what is a packet speed, who knows, so many variables based on path to server and network performance, to name a few, but I’d expect it to take many minutes, from about 3 to 30 minutes m, it’s not a desktop PC. Try it out is the answer.
Hi, what does this code exactly do and when to use it, what is it about with these brackets? in server.on I found this expression: [](){ server.send(200)}
This code runs up a ESP based WebServer, and then from the menu, you can select a file using your PC Browser and then upload the file to the ESP8266/ESP32 filing system e.g. SD card or SPIFFS. [](){server send(200)} are just empty parameters and the code 200 means HTTP OK because it's a standard response for to a successful HTTP request.
Good morning, yes I understrand that, but usualy I use the instruction in this way:"server.on("/wifi_connect", HTTP_POST, handlewifi);" to call a subroutine. But now we got these brackets like this: "server.on("/update", HTTP_POST, []() {
server.sendHeader("Connection", "close");
server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK");
ESP.restart();
}, []() {....more functions......}); Do you know where there is a reference and explained, how to use it?
SV Vela Nautica, you need to go to the web server repository on git hub, then scroll down the .cpp to send and check out the parameters. There is no documentation that explains what you want to know, if only there was!
Ok, then let me ask other way round, maybe you know? here my example again: HTTP_POST, []() { server.sendHeader("Connection", "close"); server.send(200, "text/plain", (Update.hasError()) ? "FAIL" : "OK"); ESP.restart(); }, []() {....more functions......});
I like to separate all what is in the last curly bracket into a separate subroutine. I tried to replace [] by a function name but that did not work.Do you know how to? -Oliver-
You can't do it the way your trying to do, there are separate commands that you need to use with the Webserver:
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.send(200, "text/html", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves.
server.sendContent(webpage);
server.client().stop(); // Stop is needed because no content length was sent
You need to ask the author of the Webserver why you can't use functions, that's Espressif, your trying to do something the server was not designed to do.
What is the upload speed for the ESP 8266 ?
thank
hin124 It uploads a 20K file in about 1-2 secs I have not done an accurate measurement but it’s near instantaneous. Obviously this is a micro controller so don’t expect Desktop PC performance.
max download speed I have achieved is 70Kbytes/sec
That sounds about right to me, the http protocol results in a large overhead, but it’s the only provolones that is supported by the IDE as standard there are some ftp libraries around but they are difficult to interface with for the HCI
Could I upload files that aren't .txt? And make this a wireless access point?
You can upload any file type the ESP sketch does not care, it's a binary payload whatever it happens to be when interpreted by say a browser or some other application. It can relatively easily be switched to an Access point, just prefix wifi.begin with the required mode. There is plenty of documentation via google on how to do this.
@@G6EJD thank you very much. Your videos are helping me design a portable file server.
Good luck with your project, there is a more advanced version with dir, upload and download with delete, I’m sure you’ve seen this version. See github.
@@Genericuseron hey,i am also doing similar project,i could not upload not-writable files like pdfs,i can upload images,but they are downloaded in unreadable fomat .did it work for you?
@@kmrkmr2526 I haven't attempted the project yet. I am waiting on the products to arrive to the house. I will let you know when I attempt
Any idea What is max size of sd card supported by esp 32/8266?
I'm using SDHC cards and currently a Samsung 64GB card is working just fine. The file format is FAT so no files more than 4GB. Essentially (I have not tried it all) I'd expect the SD library using FAT to do everything a PC can do using SD cards of the same size. I know 512GB cards have been used on an ESP8266 and that's the same library. In practice and for most applications a file of data of about 10MB is huge, so getting near the 1GB sizes and FAT maximum will be 4GB is extremely large files. I have not done any benchmarks but it might be slow reading through the files, but workable.
G6EJD thanks a lot 64 gb is a lot :)
Nice work ! Cool application ! What upload and download speeds we should expect in this chips ? Is any difference between them ?
The http protocol overheads are large and generally a 20K file takes about 2-secs, the ESP8266 compiler/http implementation along with all other webserver functions is faster than the ESP32 in all regards. I think the eSP8266 had a lot more compiler development than the ESP32 so-far.
can I using html upload mp3 to esp32 .
Http can upload any data file to the ESP32
@@G6EJD
HTTP can run in phone
I want to upload my file
to esp32 on my phone
@@สุพงศ์เอง Your phone can connect to the ESP32 and yes will use http like it does for all web pages, you would select the file to upload and then upload it
Nice work, could you please upload the final version of you code on the gihub .
Thanks, the link to the code is in the video description. I’ve just checked and the link is ok.
@@G6EJD Hi, really great video. Howeverm the version on the github appears to be missing the directory option. Could you update the version please?
Thank you.
Cheers, Luís Pereira.
I’ve just checked and the code is there on GitHub
@@G6EJD You're right. The 'directory' version is on the repository: github.com/G6EJD/G6EJD-ESP-File-Server, and not the repository referred on the video description, correct?
Thank you.
IS it possible to upload hexcodes SPIFFS
Hex codes? Do you mean a binary format data file, ie not structured?
@@G6EJD audio file
.How to upload that file using http webpage using form in HTML
Hi, i only need send video(max 1mb) without any interface. How can i do it?
Do you mean transfer a single file or to stream it? You can transfer a file but using http will take some time (many minutes) to complete. I have not produced a streaming version.
@@G6EJD Yes, i mean a single file. Maximum 1mb video file will be sended. Aproximately how much time will it take to send video? http is not the right way to do it? My project is that connect from Pc to Esp and send 1mb(max.) video file. Do you have any idea for this? Which one is the right way to do it?
@@kemrandavrishov9341 it’s difficult to determine the exact transfer time the best way to find out how long is to transfer and time a 1K file, then 10K and 100K from the timings it’s easy to work out the 1MB transfer time. You have no choice about transfer protocol as it can only be done using http. There are some ftp libraries around but they are harder to use/integrate with code and are a bit experimental.
I have provided a file upload example.
@@G6EJD First of all thank you so much. İ need send video from Ground station program(python desktop application) to the esp3286 over wifi. İ only need select video from GCS program and click the send button to send video.İ actually dont know web interface is necessary for me? İ dont wanna send video from browser. How can i do it?
can i upload audio file
Yes you can, it can be any format of file as the routine does not care, but don’t expect it to process and play the file.
ERROR While uploading "Architecture is not compatible "
I am using ESP32 DOIT DEV KIT V1
Did you install the ESP32 support
@@G6EJD what is the supporting file ?
I installed ESP32 BOARD
EXTRA LIBRARY of server FROM GITHUB
What are you trying to transfer?
@@G6EJD Thanks for replying.
i couldn't connect even using ip address in browser. But it is connected to my hotspot. How cam i solve this problem...
@@mithunxavior , what ip address does it report in the serial port you need to connect to that
Awesome!!
thanks
1000 LIKES
can i upload 500Kb .mp4 or avi format Video file ?
Well you can, have you tried it, but do t forget the ESP32 has relatively limited memory and it’s not a PC and was never designed to handle large files.