我需要使用 php POST 发送原始多部分数据,但没有 html 表单...我使用 jquery $.post() 开始该过程(目标是更改 Twitter 帐户的背景)。
我怎样才能做到这一点?这是我当前(但仍然不完整)的代码:
1)图像文件名被插入到这个隐藏的输入字段中:
<input type="hidden" id="profile_background_image_url" value="oats.jpg" />
2)当点击提交按钮时,一个javascript函数被触发......它调用:
$.post('helper.php',{
profile_background_image_url:$('#profile_background_image_url').val()
});
3) helper.php有
$param = array();
$param['image'] = '/www/uploads/'.$_POST['profile_use_background_image'];
$status = $connection->post('account/update_profile_background_image',$param);
备注:
- 所有背景文件都在/www/uploads本地目录中。
- 我正在使用 Abraham Williams 的 twitteroauth 库 0.2
底线,在第三步中,我需要将原始多部分数据中的$param['image']发送到$connection对象(twitter 库)。
有任何想法吗?
一些参考资料:http ://dev.twitter.com/doc/post/account/update_profile_background_image