php - 使用multipart / form-data没有$ _POST值

时间:2014-02-14 02:09:37

标签: java apache http post multipartform-data

问题很简单。我在要求:

POST /api/?user=auth HTTP/1.1 Content-Length: 437 Content-Type: multipart/form-data; boundary=tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg; charset=UTF-8 Host: 192.168.0.10:8888 Connection: Keep-Alive User-Agent: Apache-HttpClient/UNAVAILABLE (java 1.4)

--tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg Content-Disposition: form-data; name="token"

KJjhyuJHYsadfU78
--tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg Content-Disposition: form-data; name="api_login"

9053494481
--tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg Content-Disposition: form-data; name="api_password"

8013468v30
--tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg Content-Disposition: form-data; name="api_terms"

no
--tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg--

并在PHP中接收$ _POST === array()。

PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v1.0-dev, Copyright (c) 2004-2012 eAccelerator, by eAccelerator

Server version: Apache/2.2.15 (Unix)

检查服务器是否有可能丢失数据的重写重定向 - 找不到。 请帮忙。

已解决:我使用apache库发送多部分请求。它产生了标题:

Content-Type: multipart/form-data; boundary=tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg; charset=UTF-8

当我删除编码设置时,它更改为:

Content-Type: multipart/form-data; boundary=tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg

现在一切顺利。

2 个答案:

答案 0 :(得分:0)

这是一个GET方法!

使用:

$_GET

答案 1 :(得分:0)

已解决:我使用apache库发送多部分请求。它产生了标题:

Content-Type: multipart/form-data; boundary=tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg; charset=UTF-8

当我删除编码设置时,它更改为:

Content-Type: multipart/form-data; boundary=tYhL_Uv6shSE9A9DHwvtJvXb0NPSLNMsdg

现在一切顺利。