标签: post

JSOUP + multipart/form-data响应

下午好,

通常,我需要通过JSOUP以响应multipart/form-data的形式将数据发送到站点

例如,采用sgeniriruet您的查询的简单形式.

<form action =« localhost:8000 »method =«post»enctype =«multipart/form-data»
<input type =«text»name =«text»value =«text default»
<input type =«file»name = «file1»
<input type =«file»name =«file2»
Submit </ button
</ form

通过浏览器发布回复:

>Request Headers Provisional headers are shown Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Content-Type:multipart/form-data;
boundary=----WebKitFormBoundaryjtkXVNw9YVG1H2P9 Origin:null
Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106
Safari/537.36
X-DevTools-Emulate-Network-Conditions-Client-Id:8DCCE949-56FA-4AB0-81B7-DA2BC7960E5C

->Request Payload
------WebKitFormBoundaryjtkXVNw9YVG1H2P9 Content-Disposition: form-data; name=«text»

text default
------WebKitFormBoundaryjtkXVNw9YVG1H2P9 Content-Disposition: form-data; name=«file1»; filename="" Content-Type:
application/octet-stream

------WebKitFormBoundaryjtkXVNw9YVG1H2P9 Content-Disposition: form-data; name=«file2»; filename="" Content-Type:
application/octet-stream

------WebKitFormBoundaryjtkXVNw9YVG1H2P9--
Run Code Online (Sandbox Code Playgroud)

我试图创建一个类似的请求,但没有找到正确的方法,以便服务器收到请求.

我的代码:

Map<String, …
Run Code Online (Sandbox Code Playgroud)

java post multipartform-data jsoup

0
推荐指数
1
解决办法
2672
查看次数

HTML PHP表单帖子显示空白?

我有两个文件,testpage.html和testpage.php在同一个文件夹中.

这是testpage.html

<!DOCTYPE HTML>
<html>
<body>

<form action="testpage.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是testpage.php

<html> 
<body>

Welcome <?php echo $_POST["name"]; ?><br> 
Your email address is: <?php echo $_POST["email"]; ?><br> 

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

表单似乎工作正常,但是当我点击提交时,下一页上没有显示任何内容.无论我输入什么形式,它总是显示"欢迎""你的电子邮件地址是:"之后没有任何输入,就像它应该的那样.

我有错误的配置吗?我使用错误的浏览器(firefox)?

谢谢!

html php post

0
推荐指数
1
解决办法
432
查看次数

如何在Node.js上更改接收POST数据的大小限制

我的Angularjs应用将XML字符串作为POST数据发送到Node.js服务器。

var xmlString = (new XMLSerializer()).serializeToString(xmlData);
var fd = new FormData();
fd.append('xml', xmlString);
$http.post("/saveXML", fd, {
    transformRequest: angular.identity,
    headers: {'Content-Type': undefined}
}).success(function (response) {
    console.log('xml uploaded!!', response);
}).error(function (error) {
    console.log("Error while uploading the xml!");
});
Run Code Online (Sandbox Code Playgroud)

然后Node.js接收数据并将其写入文件。

app.post('/saveXML', function (request, response) {
    var xmlData = request.body.xml;
    console.log(request.body);
    fs.writeFile("./uploads/mergedXml.xml", xmlData, function(wError){
        if (wError) {
            console.log(wError.message);
            response.send({
                success: false,
                message: "Error! File not saved!"

            });
            throw wError;
        }
        console.log("success");
        response.send({
            success: true,
            message: "File successfully saved!"
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

问题是,如果发送的XML字符串(POST xml数据)大于1MB,则Node.js(?)将其截断为1MB …

post node.js angularjs

0
推荐指数
1
解决办法
1249
查看次数

使用Gson将自定义类的ArrayList序列化为JSON并通过HTTP发送数据

我想将ArrayList中的数据转换为JSON,然后将其发送到我的网络服务器.列表mTeamDataList是类型ArrayList<TeamData>.

TeamData堂课是:

public class TeamData
{
    String mFullName;
    String mShortName;
    String mLeague;

    //constructor, getters and setters are here
}
Run Code Online (Sandbox Code Playgroud)

我有一个addTeamsToDB()方法负责将数组中的数据写入Web服务器.这是我到目前为止:

public static void addTeamsToDB()
{
    if(mTeamDataList.size() == 0)
        return;

    HttpURLConnection urlConnection = null;
    String addTeamURL = "http://api.somewebsite.com/add_team.php";

    try
    {
        Gson gson = new Gson();
        URL urlObj = new URL(addTeamURL);
        urlConnection = (HttpURLConnection) urlObj.openConnection();
        urlConnection.setDoOutput(true);
        urlConnection.setRequestMethod("POST");
        urlConnection.connect();

        //I believe converting to json goes here

        OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());

    } 
    catch (IOException e) …
Run Code Online (Sandbox Code Playgroud)

java post android json gson

0
推荐指数
1
解决办法
7104
查看次数

Make Go http.Response详细说明所有参数

我有一个问题,从Android应用程序发送参数进入应用程序.我调用了r.FormValue(key),但它返回null.我想找到在Android应用程序发送帖子数据后检查Go端可用参数的方法.有没有办法做到这一点,不使用键获取所有参数?

post android http go

0
推荐指数
1
解决办法
66
查看次数

如何在php函数中使用$ _POST作为参数

好的,所以我一直在尝试用一个$_POST参数创建一个PHP函数.我已经阅读了很多关于$ _POST作为全局变量的帖子,但我似乎无法得到它.我一直试图让这些代码与许多变体一起工作,但我似乎无法找到正确的公式.

这是我的代码:

if($_POST['fname']){
$testing = $_POST['fname']
} 
function myTest($test)
{
    if($test)
    {
    $id=14; 
    $sql = "UPDATE stud_bas set fname=:fname WHERE stud_id=:id";
    $query = $db ->prepare($sql);
    $query -> bindValue  (':fname', $test);
    $query -> bindValue (':id', $id);
    $update = $query -> execute();
    }
}
Run Code Online (Sandbox Code Playgroud)

MYTEST($测试);

基本上,我正在尝试创建一个函数,其中不同的函数$_POST可以使用相同的函数.它仍然在被修改的当前功能.

但最重要的是我无法$_POST为功能做好工作......
对不起,我没注意到我没有包含我如何调用该功能.我刚刚用过

myTest($testing); 另一个变化是我插入myTest($testing);里面if($_POST)

php post

0
推荐指数
1
解决办法
85
查看次数

在这种情况下,为什么jquery不调用成功处理程序?

我有这个代码:

$.post( "/ankauf/", {
        "kunden_id" : 1,
        "products" : products,
        "full_price" : parseInt($('#totalPrice').text()),
        "_token" : $('meta[name="csrf-token"]').attr('content')
    },
    function( data ) {            
        toastr.success("Ankauf abgeschlossen", "OK!");
    }
);
Run Code Online (Sandbox Code Playgroud)

这会向我的服务器发出一个帖子请求,就像我在我的应用程序中经常这样做.

Chrome会像这样显示此请求:

Request Method:POST  
Status Code:200 OK  
Remote Address:192.168.178.80:1414  
Run Code Online (Sandbox Code Playgroud)

响应如下所示:

Cache-Control:no-cache  
Connection:close  
Content-Type:application/json

Response content:  
array(7) {  
  ["product_id"]=>  
  string(1) "5"  
  ["paidprice"]=>  
  string(2) "85"  
  ["condition"]=>  
  string(8) "Sehr Gut"  
  ["ovp1"]=>  
  string(1) "0"  
  ["ovp2"]=>  
  string(1) "0"  
  ["ovp3"]=>  
  string(1) "0"  
  ["ovp4"]=>  
  string(1) "0"  
}  
{"full_price":"85","updated_at":"2016-06-27 14:01:55","created_at":"2016-06-27 14:01:55","id":73,"created_by_id":1,"customer_id":1}
Run Code Online (Sandbox Code Playgroud)

所以Servers响应看起来像一个有效的JSON响应,http代码是200任何想法为什么成功处理程序不会触发?

javascript jquery post json

0
推荐指数
1
解决办法
41
查看次数

XHR加载失败:POST

所以我试图用ajax发布,但它不会通过。

这是我的javascript

$.ajax({
      type: 'POST',
      contentType: "",
      url: 'some url',
      data: order,
      dataType: 'json',
      success: function() {
        Materialize.toast('Order added successfully', 4000, 'android-success');
        console.log('order posted');

      },


      error: function() {
        Materialize.toast('Something went wrong', 4000, 'android-error');
      }

    }); // $.ajax post
Run Code Online (Sandbox Code Playgroud)

我没有收到错误,也没有从ajax获得成功。但是我收到上面列出的Chrome控制台错误XHR failed loading: POST

我尝试将内容类型和数据类型设置为无效。我的猜测是,问题出在对象格式之类的东西上。

可能有用的信息-这是我的代码的基本概述。

  1. 我有一个点击事件按钮
  2. 在那个函数中我有if else语句
  3. 如果输入字段为空白event.preventdefault(),则单击按钮
  4. 否则ajax发布

这是失败日志下的信息

send    @   jquery-3.1.0.js:9392

ajax    @   jquery-3.1.0.js:8999

(anonymous function)    @   ajax.js:20

mightThrow  @   jquery-3.1.0.js:3508

process @   jquery-3.1.0.js:3576
Run Code Online (Sandbox Code Playgroud)

在这个问题上的任何帮助都表示赞赏。

javascript ajax jquery post xmlhttprequest

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

发送字典列表作为带有请求的字典值

我有客户端服务器应用程序。我定位了麻烦,并且有这样的逻辑:

客户:

# -*- coding: utf-8 -*-
import requests


def fixing:
    response = requests.post('http://url_for_auth/', data={'client_id': 'client_id', 
                             'client_secret':'its_secret', 'grant_type': 'password', 
                             'username': 'user', 'password': 'password'})
    f = response.json()
    data = {'coordinate_x': 12.3, 'coordinate_y': 8.4, 'address': u'\u041c, 12', 
            'products': [{'count': 1, 'id': 's123'},{'count': 2, 'id': 's124'}]}
    data.update(f)
    response = requests.post('http://url_for_working/, data=data)
    response.text #There I have an Error about which I will say later
Run Code Online (Sandbox Code Playgroud)

oAuth2运作良好。但是在服务器端,request.data中没有任何产品

<QueryDict: {u'token_type': [u'type_is_ok'], u'access_token': [u'token_is_ok'], 
             u'expires_in': [u'36000'], u'coordinate_y': [u'8.4'], 
             u'coordinate_x': [u'12.3'], u'products': [u'count', u'id', u'count', 
             u'id'], u'address': [u'\u041c, 12'], …
Run Code Online (Sandbox Code Playgroud)

python django post python-requests oauth2

0
推荐指数
1
解决办法
2369
查看次数

简单的POST方法不起作用

我创建了一个帐户,所以我可以问这个问题:为什么post方法不能处理这些简单文件?

文件1上的代码:

<form method="POST" action="caralho.php">
        <input type="text" id="titulo_cardapio" />
        <input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)

文件2,"caralho.php":

<?php
$crlh = $_POST['titulo_cardapio'];
echo $crlh;
?>
Run Code Online (Sandbox Code Playgroud)

这个简单的形式不会发布变量,当我加载"caralho.php"后,点击提交按钮后,会发生这种情况:

注意:未定义的索引:第2行的C:\ xampp\htdocs\cardapio\caralho.php中的titulo_cardapio

这是怎么回事?这让我疯了

html php forms post

0
推荐指数
1
解决办法
873
查看次数