免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4065 | 回复: 1
打印 上一主题 下一主题

multipart formdata格式的post 如何用perl模拟上传文件讷 [复制链接]

论坛徽章:
3
摩羯座
日期:2013-09-04 12:01:36申猴
日期:2013-10-23 12:12:23CU十二周年纪念徽章
日期:2013-10-24 15:41:34
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-10-11 10:12 |只看该作者 |倒序浏览
本帖最后由 grshrd49 于 2013-10-14 16:14 编辑

这个是页面提交的post表单中的其中一块
改了好好多次了,普通的请求数据服务器都收到了,但是文件上传这块服务器始终没有收到,返回也没有任何错误!
有人对post请求有深入了解的没?

  1. POST data:
  2. --rqZkSQWTz_5hfkhgvH8r6garI7hGxw
  3. Content-Disposition: form-data; name="myFile"; filename="316x250.png"
  4. Content-Type: image/png
  5. Content-Transfer-Encoding: binary

  6. <actual file content, not shown here>
  7. --rqZkSQWTz_5hfkhgvH8r6garI7hGxw--
复制代码
我的代码片段

  1. ######
  2. #创建survey_title
  3. ######'C:\Users\Public\Pictures\testPic\316x250\316x250.png'
  4. open MF,"316x250.png";
  5. my $read;
  6. while(<MF>){
  7.         $read .= $_;
  8. }
  9. close MF;
  10. #print @readfile;
  11. $return_json = $ua->post("$base_url/survey/a/editSurvey",
  12.         {
  13.         paperImage=>'',
  14.         surveyTitle=>'perlscriptest2',
  15.         surveyDesc=>'descperl',
  16.         },
  17.         myFile=>$read,
  18.         filename=>"316x250.png",
  19.         'Referer'=>"$base_url/survey",
  20.         'Content-Type'=>"multipart/form-data;",
  21.        
  22. )->content;
  23. my $surveyid;
  24. $surveyid = $1 if($return_json =~ /"surveyId":"(\d+)"/);
  25. print "surveyid = $surveyid\n";
  26. print "editSurvey - $return_json\n";
  27. print FF "editSurvey - $return_json\n";
复制代码

论坛徽章:
3
摩羯座
日期:2013-09-04 12:01:36申猴
日期:2013-10-23 12:12:23CU十二周年纪念徽章
日期:2013-10-24 15:41:34
2 [报告]
发表于 2013-10-11 11:12 |只看该作者
本帖最后由 grshrd49 于 2013-10-14 16:08 编辑

没人自己顶了!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP