通过 HTML 表单发布 XML
我正在开发一个网络,希望用户可以创建一些发布 XML 数据的东西。为此,有一个
也许这是一个框架问题,不确定,我正在使用 Elgg 并使用 get_input()
接收数据。
更新1:一些代码回答评论:
<form method="POST" action="http://for.bar/slash" enctype="text/xml">
<input name="add" type="submit" value="Create" />
</form>
接收数据我使用elgg get_input()
$data = get_input('data');
I am developing a web and want to make it so that the user can create some stuff POSTing XML data. For that purpose there is a <textarea>
where the user can write (copy/paste) XML and submit it. The problem is that I am losing data: characters such as <
, >
, and I think others too, get lost.
Maybe it is a framework problem, not sure, I am using Elgg and receiving the data with get_input()
.
UPDATE1: some code answering the comment:
<form method="POST" action="http://for.bar/slash" enctype="text/xml">
<input name="add" type="submit" value="Create" />
</form>
to receive the data I use elgg get_input()
$data = get_input('data');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我在哪里进行疯狂的猜测,我会说 get_input() 使用了某种自动神奇的 xss 保护。您可以尝试执行
print_r($_POST);
或者 elgg 也可能“清理”所有 $_POST 。在这种情况下,您可能必须在提交请求之前使用 JavaScript 对数据进行 Base64 编码。If i where to make a wild guess I'd say that there is some kind of auto-magical xss protection being used by get_input(). You could try doing a
print_r($_POST);
or perhaps elgg is "sanitizing" all of $_POST as well. In this case you may have to base64 encode the data with JavaScript before submitting the request.根据 MDN,表单的
enctype
属性中应使用的唯一标准值如下:application/x-www-form-urlencoded
multipart/form-data
text/plain
也就是说,如果让它具有值
application/xml
,您可能会遇到不可预测的情况。来源: https ://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-enctype
According to MDN, the only standard values that should be used in form's
enctype
attribute are following:application/x-www-form-urlencoded
multipart/form-data
text/plain
That being said, you can run into unpredictable situations having it to have value
application/xml
.Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-enctype