如何使用 html 输入标签从用户那里获取图像并将其存储在 raspberry pi 上的文件夹中

How to get an image from a user and store it in a folder on a raspberry pi using the html input tag

我正在尝试使用 Html 中的输入标签从用户那里获取图像并将其存储在网络服务器上,该服务器目前是我的电脑,但将来我想将其传输到我的 raspberry pi 我不想为这个项目使用 SQL 服务器 我需要知道的最好是 HTML OR PHP 或 JavaScript 如何我可以从用户那里获取图像并将其存储在网络服务器上以便稍后显示吗,我目前正在使用 xampp 如果有任何用处的话。

看这道题:What's the best way to create a single-file upload form using PHP?

然后你可以写一些 bash 脚本来自动在你的电脑和树莓派之间复制文件。或者你可以在 PC 上从 RPi 挂载磁盘并直接在上面存储 html 格式的文件。

<input type="file"> 元素、change 事件、FormData()fetch()XMLHttpRequest()

处使用 change 事件
<input type="file" accepts="image/*">
<script>
var input = document.querySelector("input[type=file]");
input.addEventListener("change", function() {
  var file = this.files[0];
  var data = new FormData();
  data.append("file", file);
  fetch("/path/to/server", {method:"POST", body:data})
  .then(response => response.ok)
  .then(res => console.log(res))
})
</script>