LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1126|回复: 0

更完整的的post 模拟

[复制链接]
发表于 2007-6-4 00:46:33 | 显示全部楼层 |阅读模式
[root@petercorporation html]# cat a.html
<title>post test</title>
<form enctype="multipart/form-data" action="b.php" method="post">
<table>
<tr>
<td>userid:</td><td>  <input name="userid" /></td>
</tr>


<tr>
<td>userpwd:</td><td>  <input name="userpwd" /></td>
</tr>



<tr>
<td>userfile:</td><td><input name="userfile" type="file" /></td>
</tr>


<tr><td><input type="submit" value="Send File" /></td><td></td></tr>
</form>

以下为模拟程式
[root@petercorporation html]# cat apost.php
<?
$post_data = array();
$post_data["userid"] = "peterid" ;
$post_data["userpwd"] = "peterpwd" ;
$post_data["userfile"] = "/tmp/DNS .odt" ;
$post_data["submit"] = "submit" ;

$url = "http://localhost/b.php" ;

$o = "" ;
foreach($post_data as $k=>$v)
{
$o.= "$k=".urlencode($v)."&";
}

$postdata=substr($o,0,-1);

$ch = curl_init();
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postdata);
$result = curl_exec($ch);
curl_close($ch);
?>
是可以模拟,大家也发现了$post_data["userfile"] = "/tmp/DNS .odt" ;
也就是说我在模拟手工输入变量以及选文件。

可是我想要的是如何得到一个整个页面的所得到的输入以便直接形成一个档,
(不想用_POST这样的数组加上所得的文件的内容再程式整合成一个文件。)
复制到另一主机上后直接模拟为输出给其一样的网页做为输入。

为什么要复制,因为是不同主机。


更简单的描述:
两台主机一样的网页程式,
其中一台手工post上去的数据,(这当中包括了文件上传等)
我们如何保留成一相档,然后把这个档复制到另一主机进行POST上去.

为什么要用POST因为POST上去后我的程式会处理等等其它的问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表