SPIFFS large file[500Kb] send HTTP web server failed via ESP8266

Hi friends,

I try to Upload SPIFFS large size .txt file [500KB] in HTTP web server POST request method. But my data didn't upload my server after use the given code.

this is my code String Link = "POST/my_server_URL/HTTP/1.1"; const char*host="MY_server_IP"; File file; if (client.connect(host, port)) { client.setNoDelay(true); Dir dir = SPIFFS.openDir("/"); if (dir.next()) {

String File_name = dir.fileName(); Serial.print("File_name : "); Serial.println(File_name); file = SPIFFS.open(File_name, "r"); client.println(Link); client.print("Host: "); client.println(host); client.println("Connection: close"); client.println("Content-Type : application/x-www-form-urlencoded");

client.println("Content-Length: 124354"); Serial.println(file.size()); client.println(); client.write("bulk_data="); client.write(file); } }

Serial monitor continuously show only file name and file size otherwise server posting or connection error details not show I don't know will be next please help me.

what is on web server at "my.url"? or is it "my url"? space is not allowed in url. application/x-www-form-urlencoded is not a common format to upload a file

i never used space between URL my url is to mean for your understanding. I check this URL with ARC simulator using this application/x-www-form-urlencoded and result is data uploading well but my code not responding.

use client.write(file)

I try this commands

client.write("bulk_data="); // Variable name client.write(file); // Send File

Variable Name Only show server but file didn't show.

you open 'f' and you upload 'file'

Sorry that is my typing mistake. Now i change my code in that format but didn't working..

and Conteht-length? f.size() + size of "bulk_data="

File file; if (client.connect(host, port)) { client.setNoDelay(true); Dir dir = SPIFFS.openDir("/"); if (dir.next()) {

String File_name = dir.fileName(); Serial.print("File_name : "); Serial.println(File_name); file = SPIFFS.open(File_name, "r"); client.println(Link); client.print("Host: "); client.println(host); client.println("Connection: close"); client.println("Content-Type : application/x-www-form-urlencoded"); client.print("Content-Length: "); client.println((file.size())+strlen("bulk_data=")); Serial.println(file.size()); client.println(); client.write("bulk_data="); client.write(file); Serial.println("data posted"); } }

I try this but not Posting

try client.flush() after client.write(file). it will wait until the file is uploaded

Hi AutobotOptimus_prime and Juraj, have you solved the problem, I also have an error as AutobotOptimus_prime, not solved, hope you help, thank you very much