相关疑难解决方法(0)

ESP32 尝试使用 HTTPClient 将图像文件发送到 php

我尝试在 esp32 上运行我的代码后得到了这个

注意:未定义索引:第 23 行 C:\xampp\htdocs\acc.php 中的 imageFile

我在 esp32 上的代码

HTTPClient http;
http.begin("http://192.168.43.86/acc.php");  //Specify destination for HTTP request
http.addHeader("Content-Disposition", "form-data; name=\"imageFile\"; filename=\"picture.jpg\"\r\n");
http.addHeader("Content-type", "image/jpeg");

int httpResponseCode = http.POST(cam.getfb(), cam.getSize());


if (httpResponseCode > 0) {

  String response = http.getString();                       //Get the response to the request

  Serial.println(httpResponseCode);   //Print return code
  Serial.println(response);           //Print request answer

} else {

  Serial.print("Error on sending POST: ");
  Serial.println(httpResponseCode);

}

http.end();
Run Code Online (Sandbox Code Playgroud)

我可以使用此代码发送字符串,但我上面的代码不起作用(cam.getfb() 返回为 uint8_t,cam.getSize() 返回为 size_t)

  http.addHeader("Content-type", "application/x-www-form-urlencoded");
  int httpResponseCode = http.POST("word=" + Cword);
Run Code Online (Sandbox Code Playgroud)

php中的代码

<?php …
Run Code Online (Sandbox Code Playgroud)

php c http arduino esp32

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

arduino ×1

c ×1

esp32 ×1

http ×1

php ×1