dongtan6695 2014-11-17 18:45
浏览 88

Codeception - 通过REST sendPost发送文件

first of all, I am almost completely new to programming and completely new to codeception and PHP.

I'm wondering if anyone could help me with how I use codeception to send a file using the sendPost method in the REST module http://codeception.com/docs/modules/REST#sendPOST .

The help file describes sending it via an array but honestly can't figure it out.

The most sensible way I can come up with is the following

$I->sendPost(array("filename"))

Like I said, completely new at this.

The file is located in the directory that Codeception has been installed hence why I didn't think I needed to specify it's location. I'm also aware of how to send a Post without an attached file, just not one with an attached file.

I hope that's enough information.

Apologies if it isn't.

  • 写回答

2条回答 默认 最新

  • duanba4254 2014-11-18 09:47
    关注

    I would put the file into the tests/_data directory, and then get the path to it using codecept_data_dir:

    $I->sendPOST('/my-endpoint', ['field' => 'value'], [ 'someFile' => codecept_data_dir('file.png')]);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂