如何仅使用 http 请求和 javascript 在 http 服务器上保存文件? [英] How can I save a file on an http server using just http requests and javascript?

查看:29
本文介绍了如何仅使用 http 请求和 javascript 在 http 服务器上保存文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解 Web 服务器/html/javasacript 等的一些基础知识.我对各种 框架 中的任何一个都不感兴趣,例如 php/asp,我只是在尝试对事物进行低层次的观察(暂时).

I'm trying to understand some of the basics of web servers/html/javasacript etc. I'm not interested in any of the various frameworks like php/asp, i'm just trying to get a low level look at things (for now).

目前我正试图了解如何将数据发送到/保存在后端,但我必须承认,目前我对 w3 上的各种规格/技术内容有点迷茫!

At the moment I'm trying to understand how data can be sent to/saved on the backend, but i must admit that i'm getting a bit lost under the various specs/technical stuff on w3 at the moment!

如果我有一些数据,比如 xml,我想保存在后端,我该怎么做?

If I have some data, say xml, that I want to save on the backend how do I go about it?

我假设我必须对包含一些 javascript 的 html 文档使用类似 HTTP PUT 或 POST 请求的东西,这些 javascript 反过来会处理数据,例如把它保存在某个地方.现在通过谷歌搜索我可以看到情况似乎并非如此,所以我的假设完全错误!

I assume that I would have to use something like an HTTP PUT or POST Request to an html doc that contains some javascript that in turn would process the data, e.g. save it somewhere. Now from googling around I can see that this doesn't seem to be the case, so my assumptions are completely wrong!

那是怎么做的呢?可以做到吗,还是我必须使用php或asp之类的东西?

So how is it done? Can it be done, or do I have to use something like php or asp?

TIA.

背景

推荐答案

我假设我必须对包含一些 javascript 的 html 文档使用类似 HTTP PUT 或 POST 请求的东西,而这些 javascript 又会处理数据,例如把它保存在某个地方.

这并不完全正确.您需要使用 HTTP POST 将数据发送到 Web 服务器,但此时您需要一些服务器端脚本来处理正在发送的文件数据并对其进行处理.Javascript 是一种客户端语言,运行在用户浏览器上,而不是服务器上.

That is not entirely correct. You would need to use HTTP POST to send the data to the web server, but at that point you need some server-side script to process the file data that is being sent and do something with it. Javascript is a client-side language that runs on the users browser and not on the server.

http://www.cs.tut.fi/~jkorpela/forms/file.html 从 HTTP 角度和一些处理数据服务器端的技术很好地解释了文件上传的工作原理.

See http://www.cs.tut.fi/~jkorpela/forms/file.html for a good explanation of how file upload works from both an HTTP perspective and some techniques to process the data server side.

这篇关于如何仅使用 http 请求和 javascript 在 http 服务器上保存文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆