ASIFormDataRequest不发送post值 [英] ASIFormDataRequest doesn't send post values

查看:80
本文介绍了ASIFormDataRequest不发送post值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用ASIFormDataRequest发送一些值。问题是,即使执行了PHP脚本,也没有收到任何帖子数据。

I try to send some values using ASIFormDataRequest. The problem is that even though the php script is executed no post data is received.

这是我的工作:

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request startSynchronous];

为了检查服务器收到的内容,我有以下php测试脚本:

In order to check what the server receives I have the following php test script:

$handle = fopen("output.txt", "w");
fwrite($handle, count($_POST)."\n");
fwrite($handle, count($_GET)."\n");
fwrite($handle, count($_FILES)."\n");
foreach ($_POST as $key => $value)
{
 fwrite($handle, "POST $key=$value\n");
}
foreach ($_GET as $key => $value)
{
 fwrite($handle, "GET $key=$value\n");
}
fclose($handle);

相同的脚本适用于以下html片段:

The same script works with the following html fragment:

<FORM action="http://......."
       enctype="multipart/form-data"
       method="post">
   <P>
   What is your name? <INPUT type="text" name="submit-name"><BR>
   <INPUT type="submit" value="Send"> <INPUT type="reset">
 </FORM>

因为html片段与php脚本一起使用,我怀疑php和服务器不是问题。

Because the html fragment works with the php script I suspect the php and server are not the problem.

但是我没有丝毫想到为什么ASIFormDataRequest从我的iPhone调用时不起作用。

But I don't have the slightest idea why ASIFormDataRequest doesn't work when called from my iPhone.

有人可以帮帮我吗?

问候,
Sascha

Regards, Sascha

推荐答案

我终于找到了原因:服务器从site.com重定向到www.site.com并因此丢失了帖子值。如果没有这种重定向,一切正常。希望这会有所帮助。

I finally managed to find the reason: the server was redirecting from site.com to www.site.com and losing the post values because of that. Without this redirect everything works fine. Hope this helps.

这篇关于ASIFormDataRequest不发送post值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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